Skip to content

Commit

Permalink
fix(application-aod): Validation needed for dateofbirth (#16075)
Browse files Browse the repository at this point in the history
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
  • Loading branch information
2 people authored and thoreyjona committed Oct 2, 2024
1 parent 9c5a2e2 commit d98dc38
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,21 @@ export const dataSchema = z.object({
dateOfBirth: z.string().min(1).optional(),
dummy: z.boolean().optional(),
})
.refine(
({ name, relation, nationalId, foreignCitizenship, dateOfBirth }) => {
const hasNameAndRelation = name && relation

if (foreignCitizenship && foreignCitizenship.length !== 0) {
return Boolean(dateOfBirth) && hasNameAndRelation
} else {
return Boolean(nationalId) && hasNameAndRelation
}
},
{
message: m.errorNoDateOfBirthProvided.defaultMessage,
path: ['dateOfBirth'],
},
)
.array()
.optional(),
encountered: z.boolean().optional(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -558,6 +558,11 @@ Ef ekkert á við sem hér að ofan er talið rennur arfur í ríkissjóð. Nán
defaultMessage: 'Númer má ekki vera tómt',
description: 'Invalid general asset number error message',
},
errorNoDateOfBirthProvided: {
id: 'aod.application:error.errorNoDateOfBirthProvided',
defaultMessage: 'Fæðingardagur þarf að vera fylltur út',
description: 'Date of birth is required',
},

/* Announcement */
announcementTitle: {
Expand Down

0 comments on commit d98dc38

Please sign in to comment.