Devise は正規表現を使用してメールを検証します (正規表現を使用してこれを行うことは非常に論理的です)。
デバイスが使用する正規表現は次のとおりです: (デバイスコードからコピー)
# Email regex used to validate email formats. It simply asserts that
# an one (and only one) @ exists in the given string. This is mainly
# to give user feedback and not to assert the e-mail validity.
mattr_accessor :email_regexp
@@email_regexp = /\A[^@]+@([^@\.]+\.)+[^@\.]+\z/
デバイスを使用している場合は、デバイス初期化子でこの正規表現を変更できます。
工夫が必要ない場合は、自分でメール検証を実装できます。
非常に良いサンプルが、公式の Rails ガイドのActive Record Validations ドキュメントにあります。
class EmailValidator < ActiveModel::EachValidator
def validate_each(record, attribute, value)
unless value =~ /\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\z/i
record.errors[attribute] << (options[:message] || "is not an email")
end
end
end