jesse icon indicating copy to clipboard operation
jesse copied to clipboard

Maybe incorrect validation result

Open dziaineka opened this issue 4 years ago • 2 comments

Hello!

Trying to validate this json:

{
    "attachments": [
        {
            "mimetype": "image/jpeg",
            "content": "R0lGODlhGQAZAPMHAAAAAFpaWv+gAN+MNdDWDfj/AH1t+P///wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAgALAAAAAAZABkAAASKEMlJq7046wvA3oDgfVwoklUnrMGJIia7jmS8zgFqFzdA5B+b4LAa+GgYIYA4MBKQpZagsGwOCE9JAGjxFb6FQGEgzopz267322Frw2dLq9P+BjxScfhyJ4C3Jy0texkdUgIGRjcsGgFYAAYGAE0maRmCj5OUlo1bWz8BZFwvgAKcLxOnqKusrRsRADs=",
            "filename": "chili-pepper.jpg"
        }
    ],
    "inlines": [
        {
            "mimetype": "image/jpeg",
            "filename": "chili-pepper-inline1.jpg"
        }
    ],
    "category": "wgnc:exclusive",
    "body_html": "<HTML><body><img src=\"cid:chili-pepper-inline1.jpg\"></body></HTML>",
    "text": "test_text",
    "subject": "Autotest subject"
}

with this schema:

{
    "description": "Email message",
    "type": "object",
    "properties": {
        "subject": {
            "type": "string",
            "minLength": 1,
            "pattern": "^[^\\r\\n\\t]+$"
        },
        "text": {
            "type": "string",
            "minLength": 1
        },
        "html": {
            "type": "string",
            "minLength": 1
        },
        "from": {
            "type": "string",
            "minLength": 1
        },
        "attachments": {
            "type": "array",
            "items": {
                "type": "object",
                "required": [
                    "filename",
                    "mimetype",
                    "content"
                ],
                "properties": {
                    "filename": {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 256
                    },
                    "mimetype": {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 256
                    },
                    "content": {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 25000000,
                        "pattern": "^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$"
                    }
                }
            }
        },
        "inlines": {
            "type": "array",
            "items": {
                "type": "object",
                "required": [
                    "filename",
                    "mimetype",
                    "content"
                ],
                "properties": {
                    "filename": {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 256
                    },
                    "mimetype": {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 256
                    },
                    "content": {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 25000000
                    }
                }
            }
        }
    },
    "anyOf": [
        {
            "required": [
                "subject",
                "html"
            ]
        },
        {
            "required": [
                "subject",
                "text"
            ]
        }
    ]
}

result is:

./_build/default/bin/jesse --json /Users/a_dziaineka/Repos/jesse/test_json/email_message.json -- /Users/a_dziaineka/Repos/jesse/test_json/test.json

{"filename":"/Users/a_dziaineka/Repos/jesse/test_json/test.json","result":"ok"}

But online validator found error (link to the case):

Message:
Required properties are missing from object: content.
Schema path:
#/properties/inlines/items/required

Is it a bug?

dziaineka avatar Sep 30 '20 16:09 dziaineka

Since you demand inlines to have a required field "content", it is correct to raise an error if the actual term you supply does not have a content.

Thus, this is not a bug in the validation.

ThomasArts avatar Nov 02 '20 07:11 ThomasArts

@ThomasArts thank you!

If it is not validation bug then it is jesse bug?

Because jesse found no errors:

./_build/default/bin/jesse --json /Users/a_dziaineka/Repos/jesse/test_json/email_message.json -- /Users/a_dziaineka/Repos/jesse/test_json/test.json

{"filename":"/Users/a_dziaineka/Repos/jesse/test_json/test.json","result":"ok"}

dziaineka avatar Nov 02 '20 10:11 dziaineka