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

Maybe incorrect validation result #93

Open
dziaineka opened this issue Sep 30, 2020 · 2 comments
Open

Maybe incorrect validation result #93

dziaineka opened this issue Sep 30, 2020 · 2 comments

Comments

@dziaineka
Copy link

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?

@ThomasArts
Copy link

ThomasArts commented Nov 2, 2020

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.

@dziaineka
Copy link
Author

@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"}

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

No branches or pull requests

2 participants