|
@ -2,7 +2,7 @@ import { |
|
|
ValidatorConstraint, |
|
|
ValidatorConstraint, |
|
|
ValidatorConstraintInterface |
|
|
ValidatorConstraintInterface |
|
|
} from 'class-validator'; |
|
|
} from 'class-validator'; |
|
|
import { format, isAfter, parseISO } from 'date-fns'; |
|
|
import { format, isAfter } from 'date-fns'; |
|
|
|
|
|
|
|
|
@ValidatorConstraint({ name: 'isAfter1970' }) |
|
|
@ValidatorConstraint({ name: 'isAfter1970' }) |
|
|
export class IsAfter1970Constraint implements ValidatorConstraintInterface { |
|
|
export class IsAfter1970Constraint implements ValidatorConstraintInterface { |
|
@ -10,7 +10,7 @@ export class IsAfter1970Constraint implements ValidatorConstraintInterface { |
|
|
return `date must be after ${format(new Date(0), 'yyyy')}`; |
|
|
return `date must be after ${format(new Date(0), 'yyyy')}`; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public validate(aDateString: string) { |
|
|
public validate(aDate: Date) { |
|
|
return isAfter(parseISO(aDateString), new Date(0)); |
|
|
return isAfter(aDate, new Date(0)); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|