-1

For example {limit [5-50] for here}@email.com

email@hotmail.com -> incorrect, because count of characters input smaller then 5 tryemail@hotmail.com -> correct

Can you explain the solution ?

champ
  • 7
  • 2

1 Answers1

0

Maybe as simple as this:

local_part, domain = email.split('@')

local_part.length < 5

Though keep in mind many people do have short addresses, so don't get too strict here.

You could also do this with a regular expression:

email.match?(/\A[^@]{5,50}@[^@]+\z/)

Where that's an extremely lax parser.

tadman
  • 208,517
  • 23
  • 234
  • 262