Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

206
Views
How to check via Yup if input is mail or username?

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}$)[^_.].*[^_.]$/); 
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!