-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSchemaValidation.js
23 lines (21 loc) · 932 Bytes
/
SchemaValidation.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
// This is related to Contact.jsx. Its not used in the app but I am going to keep it because I want to.
import * as yup from "yup";
export const schema = yup.object({
name: yup
.string()
.required("Please enter your name")
.matches(/^[a-zA-Z'-\s]+$/, "Invalid name")
.min(2,"Please enter more than two alphabets"),
email: yup.string().required("Your email is required").email("Is this really an email?"),
phone: yup
.string()
.required("Please enter a phone number")
.min(10,"Phone number has to be 10 digits long").max(10,"Phone number should not be longer than 10 digits")
.matches(/^[0-9]+$/, "Must be only digits"),
gender: yup.string().required("Please select your gender"),
reason: yup.string().required("Please select the reason for connection"),
message: yup
.string()
.nullable(),
rating: yup.string().nullable().notRequired(),
});