JSON Schema fixed, commented and updated with 'qualite' conditions on 'denomination' and 'raison_sociale'

This commit is contained in:
Michael Bideau 2019-07-23 15:44:13 +02:00
parent 6b4106ae25
commit 6e709a0448
1 changed files with 94 additions and 22 deletions

View File

@ -108,15 +108,16 @@ JSON_SCHEMA_CREATE_DOSSIER_IN = {
"items": { "$ref": "#/definitions/refs-cadastrales" }
},
"autres_parcelles": {
#"enum": ["Oui","Non"]
"type": "boolean"
"type": "boolean"
},
"references_cadastrales": {
"description": "A list of 'cadastrales' references",
# conditionaly required and typed below
},
"proprietaire" : { "enum": ["Oui","Non"] },
"proprietaire_qualite" : { "type": "string" },
"qualite" : { "type": "string" },
"denomination" : { }, # conditionaly required and typed below
"raison_sociale" : { }, # conditionaly required and typed below
"nom" : { "type": "string" },
"prenom" : { "type": "string" },
"numero_voie" : { "type": "string" },
@ -142,33 +143,51 @@ JSON_SCHEMA_CREATE_DOSSIER_IN = {
"terrain_localite",
"reference_cadastrale",
"proprietaire",
"proprietaire_qualite"
"qualite",
"nom",
"prenom",
"numero_voie",
"nom_voie",
"code_postal",
"localite"
],
# conditional requirements
"allOf": [
{
# qualite
"anyOf": [
# if qualite == "Une personne physique"
# "denomination" and "raison_sociale" are not required
# and must be null
{
"properties": {
"autres_parcelles": { "const": False },
"references_cadastrales": { "type": "null" }
"qualite": { "const": "Une personne physique" },
"denomination" : { "type": "null" },
"raison_sociale": { "type": "null" }
}
},
# if qualite == "Une personne morale"
# "denomination" and "raison_sociale" are required
# and must be string
{
"properties": {
"autres_parcelles": { "const": True },
"references_cadastrales": {
"type": "array",
"items": { "$ref": "#/definitions/refs-cadastrales" }
}
"qualite": { "const": "Une personne morale" },
"denomination" : { "type": "string" },
"raison_sociale": { "type": "string" }
},
"required": ["autres_parcelles", "references_cadastrales"]
"required": ["denomination","raison_sociale"]
}
]
},
{
# proprietaire
"anyOf": [
# if proprietaire == "Oui"
# all the mandataire fields are not required
# and must be null
{
"properties": {
"proprietaire": { "const": "Oui" },
@ -179,16 +198,13 @@ JSON_SCHEMA_CREATE_DOSSIER_IN = {
"mandataire_code_postal": { "type": "null" },
"mandataire_localite" : { "type": "null" },
"mandataire_lieu_dit" : { "type": "null" }
},
"required": [
"nom",
"prenom",
"numero_voie",
"nom_voie",
"code_postal",
"localite"
]
}
},
# if proprietaire == "Non"
# all the mandataire fields are required (except the lieu_dit)
# and must be string
# and conditions are checked against mandataire_qualite
{
"properties": {
"proprietaire": { "const": "Non" },
@ -198,6 +214,7 @@ JSON_SCHEMA_CREATE_DOSSIER_IN = {
"mandataire_nom_voie" : { "type": "string" },
"mandataire_code_postal": { "type": "string" },
"mandataire_localite" : { "type": "string" },
"mandataire_qualite" : { "type": "string" },
"mandataire_lieu_dit" : { "type": ["string","null"] }
},
"required": [
@ -206,10 +223,65 @@ JSON_SCHEMA_CREATE_DOSSIER_IN = {
"mandataire_numero_voie",
"mandataire_nom_voie",
"mandataire_code_postal",
"mandataire_localite"
"mandataire_localite",
"mandataire_qualite"
],
# mandataire_qualite
"anyOf": [
# if mandataire_qualite == "Une personne physique"
# "mandataire_denomination" and "mandataire_raison_sociale" are not required
# and must be null
{
"properties": {
"mandataire_qualite": { "const": "Une personne physique" },
"mandataire_denomination" : { "type": "null" },
"mandataire_raison_sociale": { "type": "null" }
}
},
# if mandataire_qualite == "Une personne morale"
# "mandataire_denomination" and "mandataire_raison_sociale" are required
# and must be string
{
"properties": {
"mandataire_qualite": { "const": "Une personne morale" },
"mandataire_denomination" : { "type": "string" },
"mandataire_raison_sociale": { "type": "string" }
},
"required": ["mandataire_denomination","mandataire_raison_sociale"]
}
]
}
]
},
{
# autres_parcelles
"anyOf": [
# if autres_parcelles == False
# "references_cadastrales" is not required
# and must be null
{
"properties": {
"autres_parcelles": { "const": False },
"references_cadastrales": { "type": "null" }
}
},
# if autres_parcelles == True
# "references_cadastrales" is required
# and must be of type "array" of "refs-cadastrales"
{
"properties": {
"autres_parcelles": { "const": True },
"references_cadastrales": {
"type": "array",
"items": { "$ref": "#/definitions/refs-cadastrales" }
}
},
"required": ["autres_parcelles", "references_cadastrales"]
}
]
}
]
}