-
-
Notifications
You must be signed in to change notification settings - Fork 14
oneOf tests for success-caused failures #159
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -24,6 +24,95 @@ | |
| }, | ||
| "instance": "foo", | ||
| "errors": [] | ||
| }, | ||
| { | ||
| "description": "not fails with success explanation", | ||
| "schema": { | ||
| "not": { "pattern": "^a" } | ||
| }, | ||
| "instance": "apple", | ||
| "errors": [ | ||
| { | ||
| "messageId": "not-message", | ||
| "instanceLocation": "#", | ||
| "schemaLocations": ["#/not"], | ||
| "alternatives": [ | ||
| [ | ||
| { | ||
| "messageId": "pattern-success", | ||
| "messageParams": { | ||
| "pattern": "^a" | ||
| }, | ||
| "instanceLocation": "#", | ||
| "schemaLocations": ["#/not/pattern"] | ||
| } | ||
| ] | ||
| ] | ||
| } | ||
| ] | ||
| }, | ||
| { | ||
| "description": "not fails due to subschema match with success explanation", | ||
| "schema": { | ||
| "not": { | ||
| "required": ["a"] | ||
| } | ||
| }, | ||
| "instance": { "a": 1 }, | ||
| "errors": [ | ||
| { | ||
| "messageId": "not-message", | ||
| "instanceLocation": "#", | ||
| "schemaLocations": ["#/not"], | ||
| "alternatives": [ | ||
| [ | ||
| { | ||
| "messageId": "required-success", | ||
| "messageParams": { "property": "a" }, | ||
| "instanceLocation": "#", | ||
| "schemaLocations": ["#/not/required"] | ||
| } | ||
| ] | ||
| ] | ||
| } | ||
| ] | ||
| }, | ||
| { | ||
| "description": "not with nested schema producing a match", | ||
| "schema": { | ||
| "not": { | ||
| "oneOf":[ | ||
| { "required": ["a"] }, | ||
| { "required": ["b"] } | ||
| ] | ||
| } | ||
| }, | ||
| "instance": { "a": 1, "b": 2 }, | ||
| "errors": [ | ||
| { | ||
| "messageId": "not-message", | ||
| "instanceLocation": "#", | ||
| "schemaLocations": ["#/not"], | ||
| "alternatives": [ | ||
| [ | ||
| { | ||
| "messageId": "required-success", | ||
| "messageParams": { "property": "a" }, | ||
| "instanceLocation": "#", | ||
| "schemaLocations": ["#/not/oneOf/0/required"] | ||
| } | ||
| ], | ||
| [ | ||
| { | ||
| "messageId": "required-success", | ||
| "messageParams": { "property": "b" }, | ||
| "instanceLocation": "#", | ||
| "schemaLocations": ["#/not/oneOf/1/required"] | ||
| } | ||
| ] | ||
| ] | ||
| } | ||
| ] | ||
| } | ||
|
Comment on lines
+80
to
116
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This one's not quite correct. The My first thought was that I expected there to be a
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, I got it. I should change the instance to
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, I think I agree. If
We can't say "matches a schema". That's the kind of thing we're trying to avoid with this project. The reader shouldn't have to know anything about schemas to understand what's wrong with the data. We can probably come up with a message for
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok, How i am thinking about the negated message is -> let keywords optionally define a negated form of their message at the localization level, rather than introducing a global success or failure mode flag. In this case: Then So we are avoiding: I’m not sure if this fully avoids complexity, but it seems more localized than introducing parallel success or negated handlers everywhere.
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think any of that helps us avoid needing to pass a But I'm pretty sure that requires a separate pass and fail handler for each keyword. So, the thing we have to figure out is if we can make handlers be able to handle both pass and fail cases given a flag. That might not be be too hard, but applicator keywords might have some complications.
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That makes sense. Right now handlers only produce messages when the keyword fails. For example, Then handlers could support both modes: And And for applicator keywords as you have said it likely have more complications since they need to coordinate nested schemas, i would suggest to implement incrementally keyword by keyword starting with simple one to see how well the approach works before tackling applicators. |
||
| ] | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see no difference between this test and the one before it. The
notschemas are different, but there's nothing fundamentally different about what it's testing.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sorry for late reply I was travelling, yes this one and the previous one is fundamentally same except the not schema used here is
required.