class ActiveModel::Validations::ComparisonValidator
Experimental RBS support (using type sampling data from the type_fusion
project).
# sig/active_model/validations/comparison.rbs class ActiveModel::Validations::ComparisonValidator < ActiveModel::Validations::EachValidator def check_validity!: () -> nil end
:nodoc:
def check_validity!
Experimental RBS support (using type sampling data from the type_fusion
project).
def check_validity!: () -> nil
This signature was generated using 1 sample from 1 application.
def check_validity! unless (options.keys & COMPARE_CHECKS.keys).any? raise ArgumentError, "Expected one of :greater_than, :greater_than_or_equal_to, "\ ":equal_to, :less_than, :less_than_or_equal_to, or :other_than option to be supplied." end end
def validate_each(record, attr_name, value)
def validate_each(record, attr_name, value) options.slice(*COMPARE_CHECKS.keys).each do |option, raw_option_value| option_value = option_value(record, raw_option_value) if value.nil? || value.blank? return record.errors.add(attr_name, :blank, **error_options(value, option_value)) end unless value.public_send(COMPARE_CHECKS[option], option_value) record.errors.add(attr_name, option, **error_options(value, option_value)) end rescue ArgumentError => e record.errors.add(attr_name, e.message) end end