validates_format_of(*attr_names)
Instance Public methods
Validates whether the value of the specified attribute is of the correct
form, going by the regular expression provided.You can require that the
attribute matches the regular expression:
class Person < ActiveRecord::Base
validates_format_of :email, with: /\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\z/i, on: :create
end
Alternatively, you can require that the specified attribute does
not match the regular expression:
class