You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
And an errors.yml file with custom error messages:
en:
errors:
rules:
student:
rules:
name:
filled?: Student - name is missingteacher:
rules:
name:
filled?: Teacher - name is missing
It seems as if the order in which schemas are called has an effect on the output of error messages. See: run the test.rb script (with a breakpoint after schemas definitions):
[1]pry(main)> teacher.call(name: "").messages=>{:name=>["Teacher - name is missing"]}[2]pry(main)> student.call(name: "").messages=>{:name=>["Teacher - name is missing"]}
Run the script again and call schemas in different order:
[1]pry(main)> student.call(name: "").messages=>{:name=>["Student - name is missing"]}[2]pry(main)> teacher.call(name: "").messages=>{:name=>["Student - name is missing"]}
After calling the first schema an error message for subsequent schemas with duplicate key is repeated (as if it would be cached somewhere) - namespace is ignored. I'm not sure whether it is a bug or I'm just defining my schemas/error messages file in incorrect way. Has anyone encountered the same problem?
The text was updated successfully, but these errors were encountered:
@solnic Mind me pinging you but this issue is bothering us in the project - do you have any idea whether it's my fault and I should fix something or it's a bug and I should go for a workaround? Thanks in advance for the response!
Hi guys, I've encountered a strange behavior in custom error messages for duplicate keys within different namespaces. Example:
I'm having 2 schemas:
And an
errors.yml
file with custom error messages:It seems as if the order in which schemas are called has an effect on the output of error messages. See: run the
test.rb
script (with a breakpoint after schemas definitions):Run the script again and call schemas in different order:
After calling the first schema an error message for subsequent schemas with duplicate key is repeated (as if it would be cached somewhere) - namespace is ignored. I'm not sure whether it is a bug or I'm just defining my schemas/error messages file in incorrect way. Has anyone encountered the same problem?
The text was updated successfully, but these errors were encountered: