いくつかの Rails プロジェクトのメールアドレスのバリデートは、正規表現ではなく mail gem と treetop gem を組み合わせて 行なっている。 Mail::Address.new(address) でアドレスをパースできる パース結果にドメイン部分が存在し、パース結果のアドレスが同一である Treetop で解析したドメイン部分のエレメントが example.com のように 2 つ以上 しかし、mail gem のバージョン 2.6.0 から treetop gem が依存関係から削除されたため、ドメイン部分のエレメントの検証が出来なくなった。 そこで、以下のように処理を変更した。 require 'mail' require 'resolv' class EmailValidator < ActiveModel::EachValidator def validate