{
    "$schema": "http://json-schema.org/draft-04/schema#",
    "title": "Postal address for Canada",
    "description": "Postal addresses for the country of Canada",
    "type": "object",
    "properties": {
        "address": {
            "type": "object",
            "properties": {
                "name": {
                    "type": "string"
                },
                "number": {
                    "type": "string"
                },
                "street": {
                    "type": "string"
                },
                "street2": {
                    "type": "string"
                },
                "city": {
                    "type": "string"
                },
                "province": {
                    "$ref": "#/definitions/CAN_province"
                },
                "postalCode": {
                    "$ref": "#/definitions/CAN_postalCode"
                }
            },
            "additionalProperties": false,
            "required": [
                "name",
                "number",
                "street",
                "city",
                "province",
                "postalCode"
            ]
        }
    },
    "definitions": {
        "CAN_province": {
            "type": "string",
            "enum": [
                "AB",
                "BC",
                "MB",
                "NB",
                "NL",
                "NS",
                "NT",
                "NU",
                "ON",
                "PE",
                "QC",
                "SK",
                "YT"
            ]
        },
        "CAN_postalCode": {
            "type": "string",
            "pattern": "^[A-Z][0-9][A-Z]( )?[0-9][A-Z][0-9]$"
        }
    }
}