Skip to content

add anyOf case to validateSchemaType#46

Closed
paolino wants to merge 0 commit intobiocad:masterfrom
paolino:master
Closed

add anyOf case to validateSchemaType#46
paolino wants to merge 0 commit intobiocad:masterfrom
paolino:master

Conversation

@paolino
Copy link
Copy Markdown

@paolino paolino commented Apr 20, 2022

We just stumbled on one API endpoint response that has different JSON encodings format depending on a parameter request.
Moreover, those encodings have common cases where the encoding is the same.

I added a new case to the validating function so that anyOf is supported which is a simpler case of oneOf where any positive number of branches should validate to validate.

res <- forM variants $ \var ->
(True <$ validateWithSchemaRef var val) <|> (return False)
case length $ filter id res of
(npassing, _nvars) <- countPassingVariants val variants
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you really need to compute second element in the function? Looks like it's not used anywhere 🤔

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

right, I was thinking if to use the countPassingVariants also for the allOf case but I couldn't decide :-) I'm open to remove it or to use it

Comment thread stack.yaml.lock Outdated
@@ -0,0 +1,47 @@
# This file was autogenerated by Stack.
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please do not commit this file. This project doesn't really use stack for development, i keep stack.yaml for convenience of contributors, but I do not guarantee it's up to date.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants