1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74
|
{
"type": "object",
"properties": {
"street_address": {"type": "string"},
"country": {
"default": "United States of America",
"enum": ["United States of America", "Canada", "Netherlands"]
}
},
"allOf": [
{
"if": {
"properties": {
"country": {"const": "United States of America"}
}
},
"then": {
"properties": {
"postal_code": {"pattern": "[0-9]{5}(-[0-9]{4})?"}
}
}
},
{
"if": {
"properties": {"country": {"const": "Canada"}},
"required": ["country"]
},
"then": {
"properties": {
"postal_code": {
"pattern": "[A-Z][0-9][A-Z] [0-9][A-Z][0-9]"
}
}
}
},
{
"if": {
"properties": {"country": {"const": "Netherlands"}},
"required": ["country"]
},
"then": {
"properties": {
"postal_code": {"pattern": "[0-9]{4} [A-Z]{2}"}
}
}
}
]
}
# - # - # - #
type: object
properties:
'street_address': {type: string}
'country': {one of: ['United States of America', 'Canada', 'Netherlands']}
all of the following:
- if:
properties:
'country': {predefined value: 'United States of America'}
then:
properties:
'postal_code': {pattern: '[0-9]{5}(-[0-9]{4})?'}
- if:
properties:
'country': {predefined value: 'Canada'}
required: ['country']
then:
properties:
'postal_code': {pattern: '[A-Z][0-9][A-Z] [0-9][A-Z][0-9]'}
- if:
properties:
'country': {predefined value: 'Netherlands'}
required: ['country']
then:
properties:
'postal_code': {pattern: '[0-9]{4} [A-Z]{2}'}
|