Class: CrazyValidators::AlphaNumericalityValidator
- Inherits:
-
ActiveModel::EachValidator
- Object
- ActiveModel::EachValidator
- CrazyValidators::AlphaNumericalityValidator
- Defined in:
- lib/crazy_validators/alpha_numericality_validator.rb
Instance Method Summary collapse
Instance Method Details
#validate_each(record, attribute, value) ⇒ Object
5 6 7 8 9 10 11 12 |
# File 'lib/crazy_validators/alpha_numericality_validator.rb', line 5 def validate_each(record, attribute, value) return if value.nil? unless value.to_s.match(/^\w+$/) record.errors.add(attribute, :not_alpha_numeric, ) end end |