Skip to content

Instantly share code, notes, and snippets.

@mfrancois3k
Forked from phucdph/BasicForm.tsx
Last active June 7, 2022 03:35
Show Gist options
  • Save mfrancois3k/9e3629e505f1809e15075926d4ec3857 to your computer and use it in GitHub Desktop.
Save mfrancois3k/9e3629e505f1809e15075926d4ec3857 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