Skip to content

Instantly share code, notes, and snippets.

@jucemar-dimon
Created February 11, 2020 17:17
Show Gist options
  • Save jucemar-dimon/c19f8022f2f8a7b73546b166bfab43dd to your computer and use it in GitHub Desktop.
Save jucemar-dimon/c19f8022f2f8a7b73546b166bfab43dd to your computer and use it in GitHub Desktop.
const Schema = Yup.object().shape({
password: Yup.string()
.required('Campo senha vazio.')
.matches(
/^(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])(?=.*[!@#\$%\^&\*])(?=.{8,})/,
'Must Contain 8 Characters, One Uppercase, One Lowercase, One Number and One Special Case Character',
),
changepassword: Yup.string().when('password', {
is: val => (val && val.length > 0 ? true : false),
then: Yup.string().oneOf(
[Yup.ref('password')],
'Valor digitado é diferente do anterior.',
),
}),
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment