Skip to content

[CCUBE-1989][HN] Add validation schema for otp verificarion field#96

Open
nvhieu9 wants to merge 1 commit intomainfrom
CCUBE-1989
Open

[CCUBE-1989][HN] Add validation schema for otp verificarion field#96
nvhieu9 wants to merge 1 commit intomainfrom
CCUBE-1989

Conversation

@nvhieu9
Copy link
Copy Markdown

@nvhieu9 nvhieu9 commented Mar 16, 2026

Changes
Add validation schema for otp verificarion field

  • delete branch

Changelog entry

  • Add validation schema for otp verificarion field

Additional information

@nvhieu9 nvhieu9 self-assigned this Mar 16, 2026
Comment thread src/fields/otp-verification-field.ts Outdated
const requiredRule = validation?.find((rule) => rule.required);

let contactSchema = Yup.string();
if (otpTypeRule?.["otp-type"] === "email") {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's apply the validation even without specifying the otp-type validation, I think we can infer from the type

however the otp-type validation is still useful as it allows consumer to customise the error message

Comment thread src/shared/error-messages.ts Outdated
Comment on lines +60 to +61
INVALID_EMAIL: "Enter a valid email address.",
INVALID_PHONE: "Enter a valid contact number.",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we use back

  • ERROR_MESSAGES.EMAIL.INVALID
  • ERROR_MESSAGES.EMAIL.INVALID_SINGAPORE_NUMBER

@weili-govtech
Copy link
Copy Markdown
Contributor

update: otp field has been merged in FEE, validation here can be updated accordingly

  • type to be inferred from type in schema, submitted value should match schema
  • state in submission must be verified

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants