Skip to content

Instantly share code, notes, and snippets.

@phucdph
Created April 4, 2020 14:49
Show Gist options
  • Save phucdph/b22b8b0fe11efd482d8131360a87b05a to your computer and use it in GitHub Desktop.
Save phucdph/b22b8b0fe11efd482d8131360a87b05a to your computer and use it in GitHub Desktop.
[Formik] Validation Schema
const validationSchema = Yup.object().shape<IFormValues>({
name: Yup.string().required("Please enter your name"),
email: Yup.string()
.email("Please enter valid email")
.required("Please enter your email"),
username: Yup.string()
.required("Please enter username")
.min(5, "Your username is too short")
.max(30, "Your username is too long"),
password: Yup.string()
.min(5, "Your password is too short")
.max(30, "Your password is too long"),
password_confirmation: Yup.string()
.oneOf([Yup.ref("password"), null], "Password does not match")
.required("Please retype password")
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment