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 }