Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

errors(full: true), for nested input, could be better #731

Open
jaredbeck opened this issue Jul 26, 2023 · 1 comment
Open

errors(full: true), for nested input, could be better #731

jaredbeck opened this issue Jul 26, 2023 · 1 comment

Comments

@jaredbeck
Copy link

jaredbeck commented Jul 26, 2023

Describe the bug

result = contract.call(params)

# errors(full: false) works fine ..
result.errors.to_h.to_json
# "{\"items\":{\"0\":{\"weight\":{\"unit\":[\"must be one of: g, kg, lb, oz\"]}}}}"

# errors(full: true), for nested input, could be better
result.errors(full: true).to_h.values.join(', ')
# "{0=\u003e{:weight=\u003e{:unit=\u003e[\"unit must be one of: g, kg, lb, oz\"]}}}"

I'm happy to attempt a PR, if requested.

To Reproduce

Call a Contract that validates nested input, as shown above. If the above is unclear, I'm happy to provide more detail.

Expected behavior

It'd be great to have better output. For example:

result.errors(full: true).to_h.values.join(', ')
# "items 0 weight unit must be one of: g, kg, lb, oz"

My environment

  • Affects my production application: No, because I guess I won't be using errors(full: true) in production .. :)
  • Ruby version: 2.7
  • OS: N/A
@flash-gordon
Copy link
Member

Could you please post sample code for reproducing it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants