'yup validation not work on develop eivorment
I have a yup validation on signup form. everything works good on localhost but not on develop. I use cognito but on development after type wrong password validation message not showing but cognito back with information that password not match. On local host i can't send form to cognito becouse yup block form and showing error message. I need to first check yup then send form to cognito.
yup:
yup
.string()
.required(t(`forms:validation.isRequired`, { fieldName: t('forms:labels.password') }))
.matches(/^(?=.*[A-Za-z])(?=.*\d)(?=.*[@$!%*#?&])[A-Za-z\d@$!%*#?&]{8,}$/, {
message: t('forms:validation.password'),
});
export const signUpFormSchema = (t: TFunction) =>
yup.object({
email: emailValidation(t),
password: passwordValidation(t),
terms: yup.bool().oneOf([true], t('forms:errors.terms')),
});
OnSubmit in form
toast.loading(t('forms:actions.registerInProgress'));
try {
await signUpToCognito({
email,
password,
});
await signInToCognito({ email, password });
toast.success(t('forms:actions.successRegister'));
Router.push('/auth/verify-email');
} catch (e) {
toast.error(t('forms:actions.failedRegister'));
}
};
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
