-
-
Notifications
You must be signed in to change notification settings - Fork 99
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
python: Add instance and kind from ValidationError #650
Comments
That's awesome! For the next minor version, I was thinking about overhauling everything related to errors, including customizing error messages for both, Rust & Python. I think that exposing these fields is a viable option, however, I'd like to spend some extra time on design to ensure features like internationalization (see #382) are ergonomic enough to use. |
Added these two attributes, I hope they will help with your use case :) I was also thinking that later there could be extra attributes from the Rust’s enum, but it will require some work |
Thank you! Yes, things like AdditionalProperties.unexpected and Required.property would be very useful to retain. For things like ExclusiveMinimum.limit, I could use schema_path to look up the limit, but for the others mentioned, I’d need to reevaluate the validation keyword to get the values needed to construct my own error messages, etc. |
I’m wondering whether |
I've spent a bit of time on complex enums, but it didn't work straight away because I wanted to keep inner exceptions (e.g. in
Assuming you meant |
This one should work - #656 I am going to add some more details into referencing errors and such, so it can be properly introspected. |
Seems like |
Awesome! 🎉 |
I see the Rust crate's ValidationError has these fields:
jsonschema/crates/jsonschema/src/error.rs
Lines 17 to 26 in b8eef87
instance
andkind
would be very useful in the Python package's ValidationError, to be able to construct our own error messages (like how fmt::Display uses thekind
) and to add other logic related to thekind
.jsonschema/crates/jsonschema-py/python/jsonschema_rs/__init__.pyi
Lines 35 to 38 in b8eef87
The text was updated successfully, but these errors were encountered: