|
|
@ -58,11 +58,12 @@ module ActiveModel |
|
|
|
# dependent on specific errors (which we use in the APIv3). |
|
|
|
# dependent on specific errors (which we use in the APIv3). |
|
|
|
# We therefore add a second information store containing pairs of [symbol, translated_message]. |
|
|
|
# We therefore add a second information store containing pairs of [symbol, translated_message]. |
|
|
|
def add_with_storing_error_symbols(attribute, message = :invalid, options = {}) |
|
|
|
def add_with_storing_error_symbols(attribute, message = :invalid, options = {}) |
|
|
|
|
|
|
|
error_symbol = options.fetch(:error_symbol) { message } |
|
|
|
add_without_storing_error_symbols(attribute, message, options) |
|
|
|
add_without_storing_error_symbols(attribute, message, options) |
|
|
|
|
|
|
|
|
|
|
|
if store_new_symbols? |
|
|
|
if store_new_symbols? |
|
|
|
if message.is_a?(Symbol) |
|
|
|
if error_symbol.is_a?(Symbol) |
|
|
|
symbol = message |
|
|
|
symbol = error_symbol |
|
|
|
partial_message = normalize_message(attribute, message, options) |
|
|
|
partial_message = normalize_message(attribute, message, options) |
|
|
|
full_message = full_message(attribute, partial_message) |
|
|
|
full_message = full_message(attribute, partial_message) |
|
|
|
else |
|
|
|
else |
|
|
@ -70,7 +71,7 @@ module ActiveModel |
|
|
|
full_message = message |
|
|
|
full_message = message |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
writable_symbols_and_messages_for(attribute) << [symbol, full_message] |
|
|
|
writable_symbols_and_messages_for(attribute) << [symbol, full_message, partial_message] |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
@ -142,8 +143,8 @@ class Reform::Contract::Errors |
|
|
|
@store_new_symbols = true |
|
|
|
@store_new_symbols = true |
|
|
|
|
|
|
|
|
|
|
|
errors.keys.each do |attribute| |
|
|
|
errors.keys.each do |attribute| |
|
|
|
errors.symbols_and_messages_for(attribute).each do |symbol, message| |
|
|
|
errors.symbols_and_messages_for(attribute).each do |symbol, full_message, partial_message| |
|
|
|
writable_symbols_and_messages_for(attribute) << [symbol, message] |
|
|
|
writable_symbols_and_messages_for(attribute) << [symbol, full_message, partial_message] |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|