Skip to content

Commit

Permalink
Events v2: form field validation example (#343)
Browse files Browse the repository at this point in the history
* add conditional rules for action visibility

* add more actions and conditionality

* do not show register action after a record already has a register action

* add example form field validation

* comment out file field for now

* remove conditionals

* update toolkit version
  • Loading branch information
rikukissa authored Dec 16, 2024
1 parent 0e1995e commit 30b930a
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
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

0 comments on commit 30b930a

Please sign in to comment.