@@ -8,6 +8,7 @@ import { getApplicationSubmissionScenarios } from '~/.server/domain/person-case/
8
8
import { getTypesOfApplicationToSubmit } from '~/.server/domain/person-case/services/application-type-service' ;
9
9
import { serverEnvironment } from '~/.server/environment' ;
10
10
import { countryService , provinceService } from '~/.server/shared/services' ;
11
+ import { stringToIntegerSchema } from '~/.server/validation/string-to-integer-schema' ;
11
12
import { APPLICANT_STATUS_IN_CANADA } from '~/domain/constants' ;
12
13
import { getStartOfDayInTimezone , isDateInPastOrTodayInTimeZone , isValidDateString } from '~/utils/date-utils' ;
13
14
import { REGEX_PATTERNS } from '~/utils/regex-utils' ;
@@ -407,23 +408,20 @@ export const primaryDocumentSchema = v.intersect([
407
408
v . regex ( REGEX_PATTERNS . NON_DIGIT , 'protected:primary-identity-document.last-name.format' ) ,
408
409
) ,
409
410
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 ( ) ,
412
412
v . minValue ( 1 , 'protected:primary-identity-document.date-of-birth.invalid-year' ) ,
413
413
v . maxValue (
414
414
getStartOfDayInTimezone ( serverEnvironment . BASE_TIMEZONE ) . getFullYear ( ) ,
415
415
'protected:primary-identity-document.date-of-birth.invalid-year' ,
416
416
) ,
417
417
) ,
418
418
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 ( ) ,
421
420
v . minValue ( 1 , 'protected:primary-identity-document.date-of-birth.invalid-month' ) ,
422
421
v . maxValue ( 12 , 'protected:primary-identity-document.date-of-birth.invalid-month' ) ,
423
422
) ,
424
423
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 ( ) ,
427
425
v . minValue ( 1 , 'protected:primary-identity-document.date-of-birth.invalid-day' ) ,
428
426
v . maxValue ( 31 , 'protected:primary-identity-document.date-of-birth.invalid-day' ) ,
429
427
) ,
@@ -442,23 +440,20 @@ export const primaryDocumentSchema = v.intersect([
442
440
) ,
443
441
) ,
444
442
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 ( ) ,
447
444
v . minValue ( 1 , 'protected:primary-identity-document.citizenship-date.invalid-year' ) ,
448
445
v . maxValue (
449
446
getStartOfDayInTimezone ( serverEnvironment . BASE_TIMEZONE ) . getFullYear ( ) ,
450
447
'protected:primary-identity-document.citizenship-date.invalid-year' ,
451
448
) ,
452
449
) ,
453
450
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 ( ) ,
456
452
v . minValue ( 1 , 'protected:primary-identity-document.citizenship-date.invalid-month' ) ,
457
453
v . maxValue ( 12 , 'protected:primary-identity-document.citizenship-date.invalid-month' ) ,
458
454
) ,
459
455
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 ( ) ,
462
457
v . minValue ( 1 , 'protected:primary-identity-document.citizenship-date.invalid-day' ) ,
463
458
v . maxValue ( 31 , 'protected:primary-identity-document.citizenship-date.invalid-day' ) ,
464
459
) ,
0 commit comments