forked from M3-Academy/desafio-react-e-typescript
develop #16
@ -4,12 +4,33 @@ const messages = {
|
||||
required: '*Campo Obrigatório',
|
||||
}
|
||||
|
||||
const emailRegexPattern = /^\w+@[a-zA-Z_]+?\.[a-zA-Z]{2,3}$/
|
||||
const cpfRegexPattern = /^([0-9]){3}\.([0-9]){3}\.([0-9]){3}-([0-9]){2}$/
|
||||
const telRegexPattern =
|
||||
/\(?\+[0-9]{1,3}\)? ?-?[0-9]{1,3} ?-?[0-9]{3,5} ?-?[0-9]{4}( ?-?[0-9]{3})? ?(\w{1,10}\s?\d{1,6})?/
|
||||
const dateRegexPattern =
|
||||
/^(?:(?:31(\/|-|\.)(?:0?[13578]|1[02]))\1|(?:(?:29|30)(\/|-|\.)(?:0?[13-9]|1[0-2])\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:29(\/|-|\.)0?2\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))$|^(?:0?[1-9]|1\d|2[0-8])(\/|-|\.)(?:(?:0?[1-9])|(?:1[0-2]))\4(?:(?:1[6-9]|[2-9]\d)?\d{2})$/
|
||||
|
||||
export default Yup.object().shape({
|
||||
fullname: Yup.string().required(messages.required),
|
||||
email: Yup.string().required(messages.required).email('Email ínvalido'),
|
||||
cpf: Yup.string().required(messages.required),
|
||||
tel: Yup.string().required(messages.required),
|
||||
date: Yup.string().required(messages.required),
|
||||
socials_instagram: Yup.string(),
|
||||
fullname: Yup.string().trim().min(7).max(60).required(messages.required),
|
||||
email: Yup.string()
|
||||
.matches(emailRegexPattern, { message: 'Email ínvalido' })
|
||||
.required(messages.required)
|
||||
.email('Email ínvalido'),
|
||||
cpf: Yup.string()
|
||||
.matches(cpfRegexPattern, { message: 'CPF ínvalido' })
|
||||
.required(messages.required),
|
||||
tel: Yup.string()
|
||||
.matches(telRegexPattern, { message: 'Número de Telefone ínvalido' })
|
||||
.required(messages.required),
|
||||
date: Yup.string()
|
||||
.matches(dateRegexPattern, { message: 'Data de Nascimento ínvalido' })
|
||||
.required(messages.required),
|
||||
socials_instagram: Yup.string().matches(
|
||||
/(?:^|[^\w])(?:@)([A-Za-z0-9_](?:(?:[A-Za-z0-9_]|(?:\.(?!\.))){0,28}(?:[A-Za-z0-9_]))?)/,
|
||||
{
|
||||
messages: 'Instagram ínvalido',
|
||||
}
|
||||
),
|
||||
terms: Yup.boolean().required('*'),
|
||||
})
|
||||
|
Loading…
Reference in New Issue
Block a user