From 485675ce68b919636331eca5311327d405652982 Mon Sep 17 00:00:00 2001 From: Bernardo Waldhelm Date: Sun, 15 Jan 2023 13:37:16 -0300 Subject: [PATCH] =?UTF-8?q?refactor(home):=20refazendo=20valida=C3=A7?= =?UTF-8?q?=C3=A3o=20da=20date=20de=20nascimento,=20pois=20estava=20quebra?= =?UTF-8?q?ndo=20no=20dia=20de=20nascimento?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/schema/FormSchema.ts | 4 ++-- src/schema/validations.ts | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/schema/FormSchema.ts b/src/schema/FormSchema.ts index 92b6ab0..a852882 100644 --- a/src/schema/FormSchema.ts +++ b/src/schema/FormSchema.ts @@ -1,12 +1,12 @@ import * as Yup from 'yup'; import { cpf } from 'cpf-cnpj-validator'; -import { insta } from './validations'; +import { insta, birthDay } from './validations'; export default Yup.object().shape({ name: Yup.string().required("*Campo Obrigatório").min(3, "*No mínimo 3 digitos"), email: Yup.string().email("*Email inválido").required("*Campo Obrigatório"), cpf: Yup.string().test((value:any) => cpf.isValid(value)).required("*Campo Obrigatório"), - birthDate: Yup.date().max(new Date(), "*Data inválida!").required("*Campo Obrigatório"), + birthDate: Yup.string().matches(birthDay, "Data Inválida").required("*Campo Obrigatório"), celPhone: Yup.string().required('*Campo Obrigatório'), instagram: Yup.string().matches(insta, 'Usuário Inválido!'), acceptTerms: Yup.boolean().oneOf([true], '*'), diff --git a/src/schema/validations.ts b/src/schema/validations.ts index d69b959..b2e3bb2 100644 --- a/src/schema/validations.ts +++ b/src/schema/validations.ts @@ -1,4 +1,5 @@ export const phoneNumber = /\([1-9]{2}\) 9[0-9]\d{3}-\d{4}/; export const cpfNumber = /^[0-9]{3}.?[0-9]{3}.?[0-9]{3}-?[0-9]{2}/; export const insta = /@(?:(?:[\w][.]{0,1})*[\w]){1,29}/; +export const birthDay = /\d{2}.\d{2}.\d{4}/;