One minute
Better way to write Email Validation π§
Use URI::MailTo::EMAIL_REGEXP
in your Ruby on Rails model, to increase readability of email validation.
Code snippet π
Email validation -
validates email, format: { with: AA([a-zA-Z0-9_.+-]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\z/i }
Can be write as -
validates format: { with: URI::MailTo::EMAIL_REGEXP }
Read other posts
comments powered by Disqus