{
    "$schema": "http://json-schema.org/draft-04/schema#",
    "title": "National address",
    "description": "National portion of an address",
    "type": "object",
    "oneOf": [
        {
            "properties": {
                "country": {
                    "type": "string",
                    "enum": [
                        "CAN"
                    ]
                },
                "province": {
                    "type": "string",
                    "enum": [
                        "AB",
                        "BC",
                        "MB"
                    ]
                },
                "postalCode": {
                    "type": "string",
                    "pattern": "^[A-Z][0-9][A-Z][0-9][A-Z][0-9]$"
                }
            },
            "additionalProperties": false,
            "required": [
                "country",
                "province",
                "postalCode"
            ]
        },
        {
            "properties": {
                "country": {
                    "type": "string",
                    "enum": [
                        "USA"
                    ]
                },
                "state": {
                    "type": "string",
                    "enum": [
                        "AL",
                        "AK",
                        "AR"
                    ]
                },
                "zipCode": {
                    "type": "string",
                    "pattern": "^[0-9]{5}(-[0-9]{4})?$"
                }
            },
            "additionalProperties": false,
            "required": [
                "country",
                "state",
                "zipCode"
            ]
        },
        {
            "properties": {
                "country": {
                    "type": "string",
                    "enum": [
                        "MEX"
                    ]
                },
                "state": {
                    "type": "string",
                    "enum": [
                        "AGS",
                        "BC",
                        "BCS"
                    ]
                },
                "postalCode": {
                    "type": "string",
                    "pattern": "^[0-9]{5}$"
                }
            },
            "additionalProperties": false,
            "required": [
                "country",
                "state",
                "postalCode"
            ]
        }
    ]
}