Class: TimespanValidator

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#attribObject (readonly)

Returns the value of attribute attrib.



2
3
4
# File 'lib/timespan_validator.rb', line 2

def attrib
  @attrib
end

Instance Method Details

#validate_each(record, attribute, value) ⇒ Object



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

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