Json schema validation error

159 views
Skip to first unread message

Suresh Babu

unread,
Dec 30, 2014, 7:24:17 AM12/30/14
to json-schem...@googlegroups.com
Hi  Guys,

Hope doing well.

Facing an issue with schema validation.

schema :

{
    "type": "object",
    "id": "#",
    "required": true,
    "patternProperties": {
        "^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,6}$": {
            "type": "object",
            "required": true,
            "properties": {
                "_from": {
                    "id": "_from",
                    "type": "string",
                    "required": true
                },
                "message": {
                    "type": "object",
                    "id": "message",
                    "properties": {
                        "detail": {
                            "type": "string",
                            "id": "detail",
                            "required": true
                        },
                        "from": {
                            "type": "string",
                            "id": "from",
                            "required": true
                        }
                    }
                }
            }
        }
    }
}


json :

{
    "t...@example.com": {
        "_from": "gi...@gmail.com",
        "message": {
            "from": "Gi...@gmail.com",
            "detail": "AnyonewanttomeetmeinParis"
        }
    },

        "_from": "gi...@gmail.com",
        "message": {
            "from": "Gi...@gmail.com",
            "detail": "AnyonewanttomeetmeinParis"
        }
    }
}


Here the key email address is dynamic, somehow it doesn't validate regex for email validation.

Please correct the schema.


Thanks
Suresh

Reply all
Reply to author
Forward
0 new messages