Merge pull request 'feat(form): Adiciona validacao do formulario' (#9) from feature/Validacao into development
Reviewed-on: #9
This commit is contained in:
commit
7d100a206f
9
src/components/schema/CustonValidationsRegex.ts
Normal file
9
src/components/schema/CustonValidationsRegex.ts
Normal file
@ -0,0 +1,9 @@
|
||||
export const phoneNumber =
|
||||
/^\(?[1-9]{2}\)? ?(?:[2-8]|9[1-9])[0-9]{3}\-?[0-9]{4}$/;
|
||||
|
||||
// export const cpfNumber = /\d{3}.\d{3}.\d{3}-\d{2}/;
|
||||
export const cpfNumber =
|
||||
/^([0-9]{3}\.?[0-9]{3}\.?[0-9]{3}\-?[0-9]{2}|[0-9]{2}\.?[0-9]{3}\.?[0-9]{3}\/?[0-9]{4}\-?[0-9]{2})$/;
|
||||
|
||||
export const insta =
|
||||
/(?:^|[^\w])(?:@)([\w-](?:(?:[\w-]|(?:\.(?!\.))){0,28}(?:[\w-]))?)/;
|
20
src/components/schema/FormSchema.ts
Normal file
20
src/components/schema/FormSchema.ts
Normal file
@ -0,0 +1,20 @@
|
||||
import * as Yup from "yup";
|
||||
|
||||
import { phoneNumber, cpfNumber, insta } from "./CustonValidationsRegex";
|
||||
|
||||
export default Yup.object().shape({
|
||||
name: Yup.string().required("*Campo Obrigatório"),
|
||||
email: Yup.string()
|
||||
.email()
|
||||
.required("*Campo Obrigatório")
|
||||
.email("E-mail inválido"),
|
||||
cpf: Yup.string()
|
||||
.matches(cpfNumber, "CPF inválido")
|
||||
.required("*Campo Obrigatório"),
|
||||
telefone: Yup.string()
|
||||
.matches(phoneNumber, "numero inválido")
|
||||
.required("*Campo Obrigatório"),
|
||||
instagram: Yup.string().matches(insta, "conta inválida"),
|
||||
data: Yup.date().required("*Campo Obrigatório"),
|
||||
checkbox: Yup.boolean().oneOf([true], "*"),
|
||||
});
|
Loading…
Reference in New Issue
Block a user