class ActiveModel::Validations::OsuEmailValidator
Validates that a user's email follows the format of name.#@*.osu.edu
Public Instance Methods
validate_each(record, attribute, value)
click to toggle source
# File lib/osu_validators/osu_email_validator.rb, line 5 def validate_each(record, attribute, value) return if value.blank? && options[:allow_blank] return if !!value && options[:allow_nil] return if ::OSU::Email.valid?(value) error_message = options[:message] || "needs to be in the format name.#@*.osu.edu" record.errors.add( attribute, :osu_email, message: error_message, value: value ) end