LoginSignup
7
6

More than 5 years have passed since last update.

Rubyでメールアドレスのバリデーション

Posted at

RailsのActiveModelのバリデーションではなく、普通の処理の中でメールアドレスが正しいかどうか確かてみる

ここでは正規表現を書かずにAciveModelのバリデータである、validates_email_format_ofを使う

インストール

$ gem install validates_email_format_of

使う

require 'validates_email_format_of'

ValidatesEmailFormatOf.validate_email_format('hoge') # ["does not appear to be valid"]
ValidatesEmailFormatOf.validate_email_format('hoge@example.com') # nil

自分で正規表現を書かずに済むので楽

7
6
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
7
6