Sha256: 025106f4b65aef571c2ad32c17285c75c8e96947db318118cf4b6f647045a225

Contents?: true

Size: 319 Bytes

Versions: 1

Compression:

Stored size: 319 Bytes

Contents

class SequentialValidator < ActiveModel::Validator
  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
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
calagator-1.1.0 lib/active_model/sequential_validator.rb