Class: MinMaxValidator

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

Instance Method Summary collapse

Instance Method Details

#validate(record) ⇒ Object



7
8
9
10
11
12
13
14
# File 'lib/min_max_validator.rb', line 7

def validate(record)
  min = record.send options[:fields][:min]
  max = record.send options[:fields][:max]

  unless valid_max_value?(min: min, max: max)
    record.errors.add(options[:fields][:max], options[:fields][:msg])
  end
end