Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

improve validDate rule ans set it by default #3681

Merged
merged 5 commits into from
Aug 2, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
add test
  • Loading branch information
DavidFyon committed Aug 2, 2024
commit d3a1542e8d703491b7580e77406b8f8307a4da55
2 changes: 1 addition & 1 deletion packages/synapse-bridge/src/rules/notAfterToday/index.ts
Original file line number Diff line number Diff line change
@@ -4,7 +4,7 @@ import { ValidationRule, ValidationResult, ErrorMessages, Value } from '../types
import { defaultErrorMessages } from './locales';
import { TODAY } from '../../constants';

function formatDateToDDMMYYYY(date: Date): string {
export function formatDateToDDMMYYYY(date: Date): string {
const day = String(date.getDate()).padStart(2, '0');
const month = String(date.getMonth() + 1).padStart(2, '0');
const year = date.getFullYear();
Original file line number Diff line number Diff line change
@@ -2,6 +2,7 @@ import { notAfterTodayFn } from '@/rules/notAfterToday/index.ts'
import dayjs from 'dayjs'
import { defaultErrorMessages } from '@/rules/notAfterToday/locales'
import { it, describe, expect } from 'vitest'
import {formatDateToDDMMYYYY} from "@/rules/notBeforeToday";

const DATE_FORMAT = 'DD/MM/YYYY'

@@ -27,4 +28,9 @@ describe('notAfterTodayFn', () => {
it('returns true when value is today', () => {
expect(notAfterToday(today)).toBe(true)
})

it('returns date in DD/MM/YYYY format', () => {
const date = new Date('2021-01-01')
expect(formatDateToDDMMYYYY(date)).toBe('01/01/2021')
})
})
Loading