Skip to content

Using Charka React Select Single Option With ReactHook Form And Yup Validator #143

Answered by csandman
nguyenphucminh asked this question in Q&A
Discussion options

You must be logged in to vote

Sure, the main difference is that in your yup schema, instead of a yup.array() type you want to use a yup.object() type.

So the new schema might look something like this:

const schema = yup.object().shape({
  firstName: yup.string().required("First name is required"),
  lastName: yup.string().required("Last name is required"),
  email: yup
    .string()
    .email("Please enter a valid email")
    .required("Email is required"),
  password: yup
    .string()
    .required("Password is required")
    .min(6, "Password must be at least 6 characters"),
  passwordConfirmation: yup
    .string()
    .oneOf([yup.ref("password"), null], "Passwords must match.")
    .required("You must confirm yo…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@nguyenphucminh
Comment options

Answer selected by csandman
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants