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

[RFC] Improve Validator messages #1151

Open
rochacbruno opened this issue Jul 7, 2024 · 0 comments
Open

[RFC] Improve Validator messages #1151

rochacbruno opened this issue Jul 7, 2024 · 0 comments
Labels
Milestone

Comments

@rochacbruno
Copy link
Member

4.0.0 Breaking change, because CI jobs right now relies on the generated message pattern.

ValidationError messages are currently defined from a fixed pattern and a bit confusing.

  • "field must ne x but is is x"
  • "field must is_type_of but it is x"
  • "field must not_in [1,2,3] but it is 1"

Messages are "ok" but not very descriptive, currently users have a way to set better messages.

Validator("name", eq=3, messages={"operations": "{name} has value {value} which is incorrect for {operation}({op_value}) !"})

I want to improve those messages, I dont have ideas right now on how to implement but I want more natural messages like:

  • "ValidationError: name must not be equal to x"
  • "ValidationError: invalid type 'int' for field 'name: str'

Also, ValidationError should expose only the data from Validator such as operations, op_value, env but never print out the current value of the settings.

On Schema

pizza_topping: Annotated[str, Ne("pineapple", msg="We dont respect pineapple on Pizza!")]
@rochacbruno rochacbruno added this to the 4.0.0 milestone Jul 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant