Commit 186c8cf7 authored by Sven Franck's avatar Sven Franck Committed by GitHub

Add validation (part 1)

parent 7aded01c
...@@ -3,55 +3,82 @@ ...@@ -3,55 +3,82 @@
"$id": "https://example.com/person.schema.json", "$id": "https://example.com/person.schema.json",
"$schema": "https://json-schema.org/draft/2020-12/schema", "$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "object", "type": "object",
"definitions": {
"saneUrl": { "format": "uri", "pattern": "^https?://" }
},
"properties": { "properties": {
"created": { "created": {
"type": "string", "type": "string",
"format": "date" "format": "date",
"pattern": "^\\d{4}\\-(0?[1-9]|1[012])\\-(0?[1-9]|[12][0-9]|3[01])$"
}, },
"title": { "title": {
"type": "string" "type": "string"
}, },
"type": { "type": {
"type": "string" "type": "string",
"enum": [
"Organisation",
"Association",
"Other"
]
}, },
"logo_url": { "logo_url": {
"type": "string" "anyOf": [{
"$ref": "#/definitions/saneUrl"
}, {
"type": "string",
"maxLength": 0
}]
}, },
"location": { "location": {
"type": "object", "type": "object",
"properties": { "properties": {
"title": { "title": {
"type": "string", "type": "string",
"description": "name" "description": "Entity name"
}, },
"address": { "address": {
"type": "string", "type": "string",
"description": "Company address" "description": "Entity address"
}, },
"postal-code": { "postal-code": {
"description": "Postal code must be composed of 5 numbers equal or greater than 0", "description": "Entity postal",
"type": "string" "type": "string"
}, },
"city": { "city": {
"type": "string", "type": "string",
"description": "name" "description": "Entity city"
}, },
"country": { "country": {
"type": "string", "type": "string",
"pattern": "^[A-Z]{2}$", "pattern": "^[A-Z]{2}$",
"description": "A valid 2-digit ISO country code (ISO 3166-1 alpha-2)" "description": "Entity country - a valid 2-digit ISO country code (ISO 3166-1 alpha-2)"
}, },
"phone_contact": { "phone_contact": {
"description": "Phone number which must be equal to or greater than zero preceded by", "description": "Entity phone contact",
"type": "string" "type": "string"
}, },
"mail_contact": { "mail_contact": {
"description": "", "anyOf": [{
"type": "string" "description": "Entity email contact",
"type": "string",
"pattern": "^\\S+@\\S+\\.\\S+$",
"format": "email",
"minLength": 6,
"maxLength": 127
}, {
"type": "string",
"maxLength": 0
}]
}, },
"coordinate_list": { "coordinate_list": {
"description": "Geographical coordinates of the company", "description": "Geographical coordinates of the entity",
"type": "array" "type": "array",
"maxItems": 2,
"items": {
"type": "number"
}
} }
} }
}, },
...@@ -289,4 +316,4 @@ ...@@ -289,4 +316,4 @@
} }
} }
} }
] ]
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment