Class: ArrayValidator

Inherits:
ActiveModel::EachValidator
  • Object
show all
Defined in:
lib/array_validator.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#attribObject (readonly)

Returns the value of attribute attrib.



4
5
6
# File 'lib/array_validator.rb', line 4

def attrib
  @attrib
end

Instance Method Details

#validate_each(record, attribute, value) ⇒ Object



6
7
8
9
# File 'lib/array_validator.rb', line 6

def validate_each(record, attribute, value)
  @attrib = attribute
  record.errors[attribute] << "must be in: #{show_list}" unless contains? value
end