class ActiveModel::Validations::RegexpValidator
Public Instance Methods
validate_each(record, attribute, value)
click to toggle source
# File lib/active_validators/active_model/validations/regexp_validator.rb, line 4 def validate_each(record, attribute, value) unless valid_regexp?(value) record.errors.add(attribute) end end
Private Instance Methods
valid_regexp?(value)
click to toggle source
# File lib/active_validators/active_model/validations/regexp_validator.rb, line 13 def valid_regexp?(value) Regexp.compile(value.to_s) true rescue RegexpError false end