Skip to content

Commit

Permalink
fix(handler): validation minimum for start date should be 4 months ea…
Browse files Browse the repository at this point in the history
…rlier, not today
  • Loading branch information
sirtawast committed Apr 3, 2024
1 parent bd08f18 commit 17be57a
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import { getNumberValueOrNull } from 'shared/utils/string.utils';
import * as Yup from 'yup';

import { getValidationSchema as getDeminimisValidationSchema } from '../formContent/companySection/deMinimisAid/utils/validation';
import subMonths from 'date-fns/subMonths';

export const getValidationSchema = (
organizationType: string | undefined,
Expand Down Expand Up @@ -279,9 +280,9 @@ export const getValidationSchema = (
.required(t(VALIDATION_MESSAGE_KEYS.REQUIRED))
.test({
message: t(VALIDATION_MESSAGE_KEYS.DATE_MIN, {
min: convertToUIDateFormat(startOfYear(new Date())),
min: convertToUIDateFormat(subMonths(new Date(), 4)),
}),
test: (value = '') => validateDateWithinMonths(value, 6),
test: (value = '') => validateDateWithinMonths(value, 4),
}),
[APPLICATION_FIELD_KEYS.END_DATE]: Yup.string().required(
t(VALIDATION_MESSAGE_KEYS.REQUIRED)
Expand Down

0 comments on commit 17be57a

Please sign in to comment.