const schema = yup.object().shape({
email: yup
.string()
.required()
.email('wrong email.')
.test('unique email', 'already using', async (value) => {
try {
const res = await axios.post('/accounts/emailcheck', { email: value });
return res.data.possible;
} catch (err) {
console.error(err);
}
}),
})
const { register, handleSubmit, formState: { errors } } = useForm({ mode: 'onBlur', resolver: yupResolver(schema) });
i want use axios only (requied, email) are ok. But it works allways onBlur.
How can I validate step by step using yup and react-hook-form?