Skip to content

Enforce the required keys based on a regex pattern #591

Answered by Reskov
grmnz asked this question in Q&A
Discussion options

You must be logged in to vote

You may try to achieve one of the pattern properties required by using double negation here.
First, use a negative lookahead regex to validate that the schema does not consist only from properties that are not matched, and after that, use a "not" keyword.

{
    "$schema": "http://json-schema.org/draft-07/schema#",
    "type": "object",
    "properties": {
        "assets": {
            "anyOf": [
                {"type": "null"},
                {
                    "allOf": [
                        {
                            "not": {
                                "propertyNames": {
                                    "pattern": "^(?!Card.* (1|2|3|4|1/4)x$)",
                     …

Replies: 2 comments 6 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
6 replies
@gregsdennis
Comment options

@Reskov
Comment options

@uzogoduyah
Comment options

@grmnz
Comment options

@jdesrosiers
Comment options

Answer selected by grmnz
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
5 participants