# File lib/active_model/validations/format.rb, line 14 14: def check_validity! 15: unless options.include?(:with) ^ options.include?(:without) # ^ == xor, or "exclusive or" 16: raise ArgumentError, "Either :with or :without must be supplied (but not both)" 17: end 18: 19: if options[:with] && !options[:with].is_a?(Regexp) 20: raise ArgumentError, "A regular expression must be supplied as the :with option of the configuration hash" 21: end 22: 23: if options[:without] && !options[:without].is_a?(Regexp) 24: raise ArgumentError, "A regular expression must be supplied as the :without option of the configuration hash" 25: end 26: end
# File lib/active_model/validations/format.rb, line 6 6: def validate_each(record, attribute, value) 7: if options[:with] && value.to_s !~ options[:with] 8: record.errors.add(attribute, :invalid, options.except(:with).merge!(:value => value)) 9: elsif options[:without] && value.to_s =~ options[:without] 10: record.errors.add(attribute, :invalid, options.except(:without).merge!(:value => value)) 11: end 12: end
Disabled; run with --debug to generate this.
Generated with the Darkfish Rdoc Generator 1.1.6.