class ActiveModel::Validations::BeforeValidator
Public Instance Methods
validate_each(record, attribute, value)
click to toggle source
# File lib/can_has_validations/validators/ordering_validator.rb, line 12 def validate_each(record, attribute, value) compare_to = Array.wrap(options[:value_of] || options[:values_of] || options[:in] || options[:with]) compare_to.each do |attr_name| greater = attr_name.call(record) if attr_name.respond_to?(:call) greater ||= Time.now if attr_name==:now && !record.respond_to?(:now) greater ||= record.send attr_name next unless value && greater unless value < greater attr2 = attr_name.respond_to?(:call) ? 'it is' : record.class.human_attribute_name(attr_name) record.errors.add(attribute, :before, **options.except(:before).merge!(attribute2: attr2, value: value)) end end end