Reputation: 5603
I need to validate that my :email
attribute includes a specific attribute - @kodak.com
.
How can I do that? I am using Rails 4.
Something like:
validates_inclusion_of :email, '@kodak.com'
Upvotes: 2
Views: 2089
Reputation: 33626
You can do this:
validates :email, format: { with: /\b[A-Z0-9._%a-z\-]+@kodak\.com\z/,
message: "must be a kodak.com account" }
Upvotes: 10