Class: ColorSchemeValidator
- Inherits:
-
ActiveModel::EachValidator
- Object
- ActiveModel::EachValidator
- ColorSchemeValidator
- Defined in:
- lib/color-scheme-validator.rb
Instance Method Summary collapse
Instance Method Details
#validate_each(record, attribute, value) ⇒ Object
2 3 4 5 6 |
# File 'lib/color-scheme-validator.rb', line 2 def validate_each(record, attribute, value) unless value =~ /\A#(\h{6}|\h{3})\z/ record.errors.add(attribute, [:message] || :invalid_color_scheme) end end |