Methods
Instance Public methods
# File activemodel/lib/active_model/validations/format.rb, line 15 15: def check_validity! 16: unless options.include?(:with) ^ options.include?(:without) # ^ == xor, or "exclusive or" 17: raise ArgumentError, "Either :with or :without must be supplied (but not both)" 18: end 19: 20: check_options_validity(options, :with) 21: check_options_validity(options, :without) 22: end
# File activemodel/lib/active_model/validations/format.rb, line 5 5: def validate_each(record, attribute, value) 6: if options[:with] 7: regexp = option_call(record, :with) 8: record_error(record, attribute, :with, value) if value.to_s !~ regexp 9: elsif options[:without] 10: regexp = option_call(record, :without) 11: record_error(record, attribute, :without, value) if value.to_s =~ regexp 12: end 13: end