class RegexpValidator

Public Instance Methods

validate_each(record, attribute, value) click to toggle source
# File lib/regexp_validator.rb, line 4
def validate_each(record, attribute, value)
  unless value.nil?
    Regexp.new(value)
  end
rescue RegexpError
  record.errors.add(attribute, "is invalid regexp expression #{value.inspect}")
end