aboutsummaryrefslogtreecommitdiffstats
path: root/activemodel/lib/active_model/validations/format.rb
diff options
context:
space:
mode:
Diffstat (limited to 'activemodel/lib/active_model/validations/format.rb')
-rw-r--r--activemodel/lib/active_model/validations/format.rb6
1 files changed, 3 insertions, 3 deletions
diff --git a/activemodel/lib/active_model/validations/format.rb b/activemodel/lib/active_model/validations/format.rb
index 3b57d4fd77..6f6933205f 100644
--- a/activemodel/lib/active_model/validations/format.rb
+++ b/activemodel/lib/active_model/validations/format.rb
@@ -5,12 +5,12 @@ module ActiveModel
class FormatValidator < EachValidator
def validate_each(record, attribute, value)
if options[:with] && value.to_s !~ options[:with]
- record.errors.add(attribute, :invalid, :default => options[:message], :value => value)
+ record.errors.add(attribute, :invalid, options.except(:with).merge(:value => value))
elsif options[:without] && value.to_s =~ options[:without]
- record.errors.add(attribute, :invalid, :default => options[:message], :value => value)
+ record.errors.add(attribute, :invalid, options.except(:with).merge(:value => value))
end
end
-
+
def check_validity!
unless options.include?(:with) ^ options.include?(:without) # ^ == xor, or "exclusive or"
raise ArgumentError, "Either :with or :without must be supplied (but not both)"