Class: SequentialValidator

Inherits:
ActiveModel::Validator
  • Object
show all
Defined in:
lib/active_model/sequential_validator.rb

Instance Method Summary collapse

Instance Method Details

#validate(record) ⇒ Object



4
5
6
7
8
9
10
11
# File 'lib/active_model/sequential_validator.rb', line 4

def validate(record)
  values = options[:attributes].map do |attribute|
    record.send(attribute)
  end.compact
  if values.sort != values
    record.errors.add options[:attributes].last, "cannot be before #{options[:attributes].first}"
  end
end