I have a field that I want to validate if it is a username or a mail address. I am using Yup for validation but having trouble setting up the correct Yup schema.
If the input is neither a mail address nor a username the validation should fail. In other words, one of the two conditions must be met to pass validation.
let schema = yup.object().shape({
email: yup.string().email(),
});
// username pattern
var pattern = new RegExp(/^(?=[a-zA-Z0-9._]{5,25}$)[^_.].*[^_.]$/);