Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Events v2: form field validation example #343

Merged
merged 8 commits into from
Dec 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
"@hapi/boom": "^9.1.1",
"@hapi/hapi": "^20.0.1",
"@hapi/inert": "^6.0.3",
"@opencrvs/toolkit": "^0.0.5",
"@opencrvs/toolkit": "0.0.6-events",
"@types/chalk": "^2.2.0",
"@types/csv2json": "^1.4.0",
"@types/fhir": "^0.0.30",
Expand Down
23 changes: 22 additions & 1 deletion src/form/tennis-club-membership.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ import {
eventHasAction,
userHasScope,
and,
not
not,
field
} from '@opencrvs/toolkit/conditionals'

const TENNIS_CLUB_FORM = defineForm({
Expand Down Expand Up @@ -74,12 +75,32 @@ const TENNIS_CLUB_FORM = defineForm({
id: 'applicant.dob',
type: 'DATE',
required: true,
validation: [
{
message: {
defaultMessage: 'Please enter a valid date',
description: 'This is the error message for invalid date',
id: 'event.tennis-club-membership.action.declare.form.section.who.field.dob.error'
},
validator: field('applicant.dob').isBeforeNow()
}
],
label: {
defaultMessage: "Applicant's date of birth",
description: 'This is the label for the field',
id: 'event.tennis-club-membership.action.declare.form.section.who.field.dob.label'
}
}
// {
// id: 'applicant.image',
// type: 'FILE',
// required: false,
// label: {
// defaultMessage: "Applicant's profile picture",
// description: 'This is the label for the field',
// id: 'event.tennis-club-membership.action.declare.form.section.who.field.image.label'
// }
// }
]
},
{
Expand Down
Loading