From 17be57a224b7b1c60c8da3a55b2c96849c25fd23 Mon Sep 17 00:00:00 2001 From: Sampo Tawast Date: Wed, 3 Apr 2024 14:36:01 +0300 Subject: [PATCH] fix(handler): validation minimum for start date should be 4 months earlier, not today --- .../src/components/applicationForm/utils/validation.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/frontend/benefit/handler/src/components/applicationForm/utils/validation.ts b/frontend/benefit/handler/src/components/applicationForm/utils/validation.ts index 0a27b5261c..361826a28d 100644 --- a/frontend/benefit/handler/src/components/applicationForm/utils/validation.ts +++ b/frontend/benefit/handler/src/components/applicationForm/utils/validation.ts @@ -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, @@ -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)