Skip to content
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

Support if-then-else #37 #53

Merged
merged 22 commits into from
Jun 29, 2024
Merged

Conversation

YongHee-Kim
Copy link
Contributor

@YongHee-Kim YongHee-Kim commented Jun 27, 2024

https://json-schema.org/understanding-json-schema/reference/conditionals#ifthenelse
I've updated _validate to work on if, then, else and it passed all tests from draft7 folder within the JSON-Schema-Test-Suite

I've thought about making a separate pull request from #52

But this pull request includes #52😓, you can close #52 and only merge this PR

@odow
Copy link
Collaborator

odow commented Jun 27, 2024

Can you revert the JSONPointer stuff? Let's keep these PRs separate.

return val_else
end
return nothing
end
Copy link
Collaborator

Choose a reason for hiding this comment

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

I might have made a mistake, but I think you can write this code as:

function _if_then_else(x, schema, path)
    if _validate(x, schema["if"], path) !== nothing
        if haskey(schema, "else")
            return _validate(x, schema["else"], path)
        end
    elseif haskey(schema, "then")
        return _validate(x, schema["then"], path)
    end
    return
end

but what about the case where you have a if-then and the if fails to validate?

Copy link
Collaborator

@odow odow left a comment

Choose a reason for hiding this comment

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

LGTM, assuming tests pass.

@odow
Copy link
Collaborator

odow commented Jun 29, 2024

We don't seem to have coverage, so I just want to double check that these are actually getting tested

src/validation.jl Outdated Show resolved Hide resolved
@odow odow merged commit 783c930 into fredo-dedup:master Jun 29, 2024
8 checks passed
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