password: Yup.string().required('Please Enter your password').matches(/^(?=.\d)(?=.[!@#$%^&])(?=.[a-z])(?=.*[A-Z]).{8,}$/, 'test').required("Password is required"),
anyone here know why .matches will not bring back an error message? i really dont want to run a bunch of .test() for each criteria we want met.
seems this is an ongoing issue with Yup and the work arounds are not making sense to how we set it up in our code
i get the required message back fine but i want the message in the .match() to show if its not met
const formik = useFormik({
initialValues: { username: '', password: '', firstName: '', lastName: '' },
onSubmit: (values) => {
dispatch(checkLogin({
username: values.username,
password: values.password
}, async () => {
return await router.push("/");
}));
setSubmitted(true);
},
validationSchema: Yup.object({
username: Yup.string().email("Must be a valid email").required("Email is
required"),
password: Yup.string().required('Please Enter your password').matches(/^(?
=.*\\d)(?=.*[!@#$%^&*])(?=.*[a-z])(?=.*[A-Z]).{8,}$/, 'test').required("Password is
required"),
firstName: Yup.string().matches(/^([^0-9]*)$/).required("First name is
required"),
lasstName: Yup.string().matches(/^([^0-9]*)$/).required("First name if
required")
}),
});