Comments (5)
Cool, thanks for the update -- I have little doubt you won't completely disappear :D -- definitely understood on the hobby side!
from jsonschema.
I have a mix of thoughts, not all well-organized, so I'll try to summarize what I see right now.
- I'm okay with an alternative name.
I've found some APIs somewhat-frustrating to use when they make names for related things hard to distinguish. e.g. reason
, cause
, details
, and description
all being different strings. It's hard to know which one is which. reason
is vulnerable to this criticism.
I'm not sure that short_message
is what I would choose though, since it's possible, at least in one of my examples for maxLength
, for the message to be longer than a message
.
I really wanted to call it cause
, but I saw that's already in use. I'll need to think more about naming. Never easy! 😀
- I need to read your comment on the future refactoring direction more carefully.
This is going to take me some time to digest and make sure I understand. I'm not worried too much about it, but I haven't digested it enough to think through the implications.
- There are two things which I've conflated in my initial proposal, which are separately useful:
- messages which are static (never interpolate any values)
- info currently missing from
message
(like keyword values)
I think that both of these are features which would be nice to have.
If I were to separate those, maybe there are two new fields?
# pseudocode for the new attributes
class ValidationError:
...
# a pair of (keyword, keyword-value), e.g. `("maxLength", 3)`
keyword: tuple[str, Any]
# a string unique to the keyword validation failure, e.g. "too long" for maxLength
error_category_message: str
I'm just spitballing a little bit here.
from jsonschema.
In general this sounds fine to me -- the main two things I think I'd want to be sure of are:
- In whatever future where #119 lands it will be by splitting
ValidationError
inton
per-keyword exception classes, e.g.exceptions.failure.MinItems
,exceptions.failure.Required
,exceptions.failure.AllOf
, etc. In that world, a bunch of the error properties are going to be deprecated (e.g.ValidationError.context
which only applies to applicator keywords, so will only be an attribute onAllOf
and notRequired
exceptions). And hopefully_Error
will disappear entirely, but we'll see. I did some work to start on this but didn't finish it, mostly again because to do it right requires assembling a test suite for error messages that's better than the ad hoc one here (TestValidationErrorMessages
). It's not an insurmountable amount of work, just work, and I intend(ed) to get back to it sometime this year now that referencing is maturing (though there's an important piece of work I want to do there too which is higher priority). Anyways -- all this is relevant only inasmuch as I don't want to make that work any harder -- but I think the attribute you're proposing will be applicable to all classes, so that should be fine. - I do though want to have a name that fits, especially since choosing the right one will mean it won't need changing again as part of the above. In particular, we already have
context
andcause
-- extremely general sounding names which we use in sort of specific ways. So I want to avoid more of that, especially again to be sure the names stick when we do the Great Exception Split of 2024(hopefully). I thinkshort_message
is a bit clearer for that, but maybe there are even more ideas we can bikeshed if need be. We'll regardless have to document what you say (that it's guaranteed to not have the instance in it).
But other than the above, and a request to add tests of this property for all keywords, I'm good with it!
from jsonschema.
info currently missing from message (like keyword values)
The only known examples of this should be #119, #992 and #993 and in general it's considered a bug, but yeah the solution I'd like is what I mentioned, of course happy to elaborate or brainstorm further on it
from jsonschema.
I just wanted to drop a small note, since it's been ~1 month and I haven't done anything:
I still want to do this, but I'm trying to negotiate the scheduling at work so that I can do this during working hours. (I've had really limited hobby development time lately.)
from jsonschema.
Related Issues (20)
- jsonschema.TypeChecker with additional types fails to work after several reference resolutions by the referencing.Registry HOT 2
- validate fails to identify incorrect uuid strings HOT 3
- 'Tuple' arrays not handled correctly HOT 3
- validate() throwing exception for a valid schema HOT 1
- Draft7Validator(TyperError: create.<locals>.Validator.__init__() got an unexpected keyword argument 'registry' HOT 2
- Which is the last version not requiring Rust via its dependencies?
- Migrating From RefResolver, unable to resolve $ref
- Python NaN validates against all numeric limits, and shouldn't HOT 2
- validating nan in an enum is no longer supported HOT 1
- Need a custom ref resolver
- Support custom Registry for meta schema in check_schema HOT 4
- `"format":"date-time"` not working HOT 6
- The latest version is slower than 3.2.0 validator HOT 5
- Validation error messages changed after upgrading jsonschema version from 3.2.0 to 4.21.1 HOT 5
- multipleOf fails to validate that 4.02 is a multiple of 0.01 due to floating point math HOT 1
- Unexpected KeyError while running test suite inside GitLab Worker HOT 3
- Enhancing the multipleOf Validator for Improved Decimal Handling in jsonschema HOT 1
- @FormatChecker.checks decorator not a classmethod HOT 1
- RefResolver deprecation docs are confusing and do not explain how to replace a very simple usage (a RefResolver which just specifies a base_uri) HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from jsonschema.