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

Improve CheckError error messages #978

Open
martonvago opened this issue Jan 20, 2025 · 1 comment
Open

Improve CheckError error messages #978

martonvago opened this issue Jan 20, 2025 · 1 comment

Comments

@martonvago
Copy link
Contributor

Following Luke's suggestions, we should improve the error messages generated by jsonschema and exposed by the checks package.

So, in checks, we should do the following modifications to all errors before returning them:

  • Type error message to: f"The '{field}' field needs to be a 'string'."
  • Required error message to: f"The '{field}' field needs to have a value in it, it is required."

Some options:

  1. In validation_errors_to_check_errors, have a custom function generate the error message based on the ValidationError.
  2. Have CheckError itself generate the error message based on the validator and the name of the field when the error in constructed.

Make sure that CheckErrors raised in Sprout use these same error messages.

@martonvago
Copy link
Contributor Author

What do we think of not including the field in the message? Because it is already in the json_path and errors are stringified like:

Error at `$.id` caused by `required`: The 'id' field needs to have a value in it, it is required.

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

No branches or pull requests

1 participant