Skip to content

Commit

Permalink
🔨 Add form validator schema
Browse files Browse the repository at this point in the history
  • Loading branch information
mirsahib committed Mar 12, 2021
1 parent 899d326 commit b38d6fe
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions app/helper/validation.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import * as yup from "yup";

export const registrationSchema = yup.object({
name: yup
.string()
.required("Name is required")
.min(6, "Name is too short - should be 6 chars minimum."),
email: yup.string().required("Email is required").email(),
password: yup
.string()
.required("No password provided.")
.min(8, "Password is too short - should be 8 chars minimum.")
.matches(
/^(?=.*\d).{8,15}$/,
"Password must be between 4 and 8 digits long and include at least one numeric digit"
),
confirmPassword: yup
.string()
.oneOf([yup.ref("password"), null], "Passwords must match"),
});

0 comments on commit b38d6fe

Please sign in to comment.