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 4410242
Showing 1 changed file with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import {
validateIsTodayOrPastDate,
} from 'benefit-shared/utils/dates';
import { validateNumberField } from 'benefit-shared/utils/validation';
import startOfYear from 'date-fns/startOfYear';
import subMonths from 'date-fns/subMonths';
import { FinnishSSN } from 'finnish-ssn';
import { TFunction } from 'next-i18next';
import {
Expand Down Expand Up @@ -279,9 +279,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 4410242

Please sign in to comment.