Skip to content

Commit 2b1a62b

Browse files
fix(frontend): state machine regression (setFormData)
1 parent 06d7aab commit 2b1a62b

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

frontend/app/routes/protected/person-case/state-machine.server.ts

+5
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,11 @@ export const machine = setup({
105105
exit: {
106106
target: '.exited',
107107
},
108+
setFormData: {
109+
actions: assign(({ context, event }) => ({
110+
formData: { ...context.formData, ...event.data },
111+
})),
112+
},
108113
},
109114
states: {
110115
'exited': { type: 'final' },

frontend/app/routes/protected/person-case/validation.server.ts

+7-12
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { getApplicationSubmissionScenarios } from '~/.server/domain/person-case/
88
import { getTypesOfApplicationToSubmit } from '~/.server/domain/person-case/services/application-type-service';
99
import { serverEnvironment } from '~/.server/environment';
1010
import { countryService, provinceService } from '~/.server/shared/services';
11+
import { stringToIntegerSchema } from '~/.server/validation/string-to-integer-schema';
1112
import { APPLICANT_STATUS_IN_CANADA } from '~/domain/constants';
1213
import { getStartOfDayInTimezone, isDateInPastOrTodayInTimeZone, isValidDateString } from '~/utils/date-utils';
1314
import { REGEX_PATTERNS } from '~/utils/regex-utils';
@@ -407,23 +408,20 @@ export const primaryDocumentSchema = v.intersect([
407408
v.regex(REGEX_PATTERNS.NON_DIGIT, 'protected:primary-identity-document.last-name.format'),
408409
),
409410
dateOfBirthYear: v.pipe(
410-
v.number('protected:primary-identity-document.date-of-birth.required-year'),
411-
v.integer('protected:primary-identity-document.date-of-birth.invalid-year'),
411+
stringToIntegerSchema(),
412412
v.minValue(1, 'protected:primary-identity-document.date-of-birth.invalid-year'),
413413
v.maxValue(
414414
getStartOfDayInTimezone(serverEnvironment.BASE_TIMEZONE).getFullYear(),
415415
'protected:primary-identity-document.date-of-birth.invalid-year',
416416
),
417417
),
418418
dateOfBirthMonth: v.pipe(
419-
v.number('protected:primary-identity-document.date-of-birth.required-month'),
420-
v.integer('protected:primary-identity-document.date-of-birth.invalid-month'),
419+
stringToIntegerSchema(),
421420
v.minValue(1, 'protected:primary-identity-document.date-of-birth.invalid-month'),
422421
v.maxValue(12, 'protected:primary-identity-document.date-of-birth.invalid-month'),
423422
),
424423
dateOfBirthDay: v.pipe(
425-
v.number('protected:primary-identity-document.date-of-birth.required-day'),
426-
v.integer('protected:primary-identity-document.date-of-birth.invalid-day'),
424+
stringToIntegerSchema(),
427425
v.minValue(1, 'protected:primary-identity-document.date-of-birth.invalid-day'),
428426
v.maxValue(31, 'protected:primary-identity-document.date-of-birth.invalid-day'),
429427
),
@@ -442,23 +440,20 @@ export const primaryDocumentSchema = v.intersect([
442440
),
443441
),
444442
citizenshipDateYear: v.pipe(
445-
v.number('protected:primary-identity-document.citizenship-date.required-year'),
446-
v.integer('protected:primary-identity-document.citizenship-date.invalid-year'),
443+
stringToIntegerSchema(),
447444
v.minValue(1, 'protected:primary-identity-document.citizenship-date.invalid-year'),
448445
v.maxValue(
449446
getStartOfDayInTimezone(serverEnvironment.BASE_TIMEZONE).getFullYear(),
450447
'protected:primary-identity-document.citizenship-date.invalid-year',
451448
),
452449
),
453450
citizenshipDateMonth: v.pipe(
454-
v.number('protected:primary-identity-document.citizenship-date.required-month'),
455-
v.integer('protected:primary-identity-document.citizenship-date.invalid-month'),
451+
stringToIntegerSchema(),
456452
v.minValue(1, 'protected:primary-identity-document.citizenship-date.invalid-month'),
457453
v.maxValue(12, 'protected:primary-identity-document.citizenship-date.invalid-month'),
458454
),
459455
citizenshipDateDay: v.pipe(
460-
v.number('protected:primary-identity-document.citizenship-date.required-day'),
461-
v.integer('protected:primary-identity-document.citizenship-date.invalid-day'),
456+
stringToIntegerSchema(),
462457
v.minValue(1, 'protected:primary-identity-document.citizenship-date.invalid-day'),
463458
v.maxValue(31, 'protected:primary-identity-document.citizenship-date.invalid-day'),
464459
),

0 commit comments

Comments
 (0)