I'm using React and Yup to validate an email address.
My schema looks like this:
const registrationSchema = yup.object().shape({
email: yup.string().email().required()
})
And my code like this:
const handleOnSubmit = async () => {
const formData = {
email: props.emailInput
}
const isValid = await registrationSchema.isValid(formData)
setInputErrorState(isValid ? false : true)
}
The code above is doing the validation, but if I input a non-ASCII character like a Japanese or Chinese character it doesn't work. For example: ハロー@ハロー.com
is passing the validation.
How can I allow only ASCII or romanji characters in my validation with YUP?
Ideal scenario:
- attack.on.titan@gmail.com ✅
- black@clover.com ✅
- ハロー@ハロー.com ❌