dma61 / VBPUOdsk

3 stars 0 forks source link

Should "contains" be "items" in JSON Schema for Array Properties? #63

Open mojtaba-boroon-cardano opened 3 months ago

mojtaba-boroon-cardano commented 3 months ago

I am trying to write a schema validators for Bericht 1 to 3 but all array properties use contains. Should it be items instead of contains to define array elements? I need a clarification for this since the items schema must be valid for every item in the array, the contains schema only needs to validate against one or more items in the array.

dma61 commented 3 months ago

Please read: https://github.com/dma61/VBPUOdsk/issues/9. Does this solve the problem?

mojtaba-boroon-cardano commented 3 months ago

For instance since for pensionSchema maxContains is not 1, when we use "contains" it means only needs to validate against one or more items in the array. I think we have to use an 'items' schema, then it must be valid for every item. Should we use "items" instead of "contains" here?

"pension": { "type": "array", "uniqueItems": true, "allOf": [ { "minContains": 1, "maxContains": 999, "contains": { "$ref": "#/definitions/pensionScheme" } } ] }

dma61 commented 2 months ago

SIVI iternal: https://stichtingsivi.atlassian.net/browse/TAAK-1019

Laurens-Hamm-Cardano commented 1 month ago

What is the status of this? Can we get some clarification whether we should use "contains" (check validity of at least 1 item) or "items" (and check validity for every item)? Thanks!

h-jos commented 3 weeks ago

To expand on this, I'm not sure how necessary allOf is here. allOf is used to ensure that the given data must be valid against all of the given subschemas (i.e. that data adheres to multiple conditions). allOf is not used to ensure that all of the items in an array adhere to certain conditions.

Would the following work instead for places in the schema with arrays w/ minimum and maximum items?

"type": "array", "uniqueItems": true, "items": { "type": "#/definitions/partyContact" }, "minItems": 0, "maxItems": 9,

dma61 commented 2 weeks ago

Uit een gesprek met CTI blijkt dat "contains" in combinatie met "minContains" en "maxContains" niet geschikt is voor het vaststellen van het totale minimum- en maximumaantal items in een array. Deze combinatie valideert alleen hoeveel geldige items er zijn, maar niet hoeveel items er in totaal zijn. Om zowel het aantal als de validiteit van items te controleren, moeten "minItems" en "maxItems" gebruikt worden. Het eventueel aanpassen van de SIVI-tooling hiervoor kost doorlooptijd.