-
-
Notifications
You must be signed in to change notification settings - Fork 589
Useless error message with very long pattern #177
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
Comments
Hey! Thanks definitely for bringing this up :) I've definitely thought quickly about this before. My general thoughts have always been that I don't like using the schema to interact with developer-level things, particularly in places where the actual schema value does not literally correspond with whatever we're using it for. I'd rather have those sorts of things be configuration on validator classes, but I also think I've resisted any attempts to add custom error messaging because However, if it's just a way to make things easier even for library users, that'd be lovely of course. How about just changing reprs to use |
Using
And, ironically, truncating the regex could make the problem worse -- consider two regexes that have the same first N characters, but differ after that. There'd be no way to figure out which one failed and convert the That's why I'd really like to see some way to specify a natural language error within the (sub)schema document itself -- the relationship between the (complex) regex and its description is made obvious, and there's no need to do the kind of crazy inference between stringified regex and human-readable error message that I mocked out above. That said, if truncating the regex is the only thing that can be done without committing gross JSON Schema abuse, then so be it -- that'd be an improvement other the current state. |
Why isn't it practical to do that? What's wrong with:
or if you want it in the schema, you can have it there, and then similarly:
I see that people like doing this seemingly, my objection is basically just that there isn't something that means this in the schema, so I'm reluctant to define our own behavior (although in something like Julian/Seep I'd be probably less reluctant than in here). Would love to hear more thoughts certainly :) |
I published a little package that formats error messages for end users https://pypi.org/project/json_payload_validator/ |
The error message when an element fails pattern validation is useless when the pattern is extremely long. It would be nice to have a way to override the default message, perhaps by using the
description
field in the type subschema. E.g.:...might yield:
That overloads the use of the
description
field, though, so I'm not sure that's the best way, either. I'm happy to implement this, I just didn't want to put in a PR with an approach you wouldn't accept.Thanks!
The text was updated successfully, but these errors were encountered: