@ -26,4 +26,10 @@ describe('IsNotInTheFutureConstraint', () => {
it('Refuses a date in the future', () => {
expect(constraint.validate('2026-09-05')).toBe(false);
});
it('Leaves a value which is not a string to IsISO8601', () => {
expect(constraint.validate(undefined)).toBe(true);
expect(constraint.validate(null)).toBe(true);
expect(constraint.validate(123)).toBe(true);
@ -15,7 +15,12 @@ export class IsNotInTheFutureConstraint implements ValidatorConstraintInterface
return '$property must not be a date in the future';
}
public validate(aDate: string) {
public validate(aDate: unknown) {
// IsISO8601 refuses a value which is not a string
if (typeof aDate !== 'string') {
return true;
return !isAccountBalanceInFuture({ date: resetHours(parseISO(aDate)) });