i-VRESSE / workflow-builder

Graphical interface to build a workflow file
https://i-vresse-workflow-builder.netlify.app/
Apache License 2.0
4 stars 2 forks source link

When a value for a then|else prop is given then additionalProperties … #166

Closed sverhoeven closed 2 months ago

sverhoeven commented 2 months ago

…must be true

Fixes #164

By setting "additionalProperties: true", you can have extra global parameters using the haddock3 catalogs so giving less_io parameter is ok, but also any other is ok. As less_io is validated against schema and other additional props are always valid.

netlify[bot] commented 2 months ago

Deploy Preview for i-vresse-workflow-builder ready!

Name Link
Latest commit 2f3a2895bcdfa6c4abe2413a35d28a2f92b56f20
Latest deploy log https://app.netlify.com/sites/i-vresse-workflow-builder/deploys/66cc4db808104d0008a367d9
Deploy Preview https://deploy-preview-166--i-vresse-workflow-builder.netlify.app
Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

sverhoeven commented 2 months ago

Tried

latest ajv ```js import Ajv from 'ajv' const schema = { type: 'object', properties: { ifpar: { type: 'boolean', default: false } }, if: { properties: { ifpar: { const: true } } }, then: { properties: { thenpar: { type: 'number', minimum: 0 } } }, else: { properties: { elsepar: { type: 'number', minimum: 0 } } }, // additionalProperties: false // additionalProperties: true } const ajv = new Ajv({ // removeAdditional: "failing" }) const values = { ifpar: false, // ifpar: true, thenpar: -1, elsepar: -2 } const r2 = ajv.validateSchema(schema) console.log(r2) const r = ajv.validate(schema, values) console.log(r) console.log(ajv.errors) console.log(values) // console.log(JSON.stringify(schema, null, 2)) ```
python jsonschema ```python from jsonschema import validate schema = { "type": "object", "properties": { "ifpar": { "type": "boolean", "default": False } }, "if": { "properties": { "ifpar": { "const": True } } }, "then": { "properties": { "thenpar": { "type": "number", "minimum": 0 } } }, "else": { "properties": { "elsepar": { "type": "number", "minimum": 0 } } }, # "additionalProperties": False "additionalProperties": True } data = { "ifpar": False, # "ifpar": True, # "thenpar": 1, "elsepar": 2 } validate(data, schema) ```

They behave the same, without implicit or explicit "additionalProperties: true" any props defined in then|else block give additionalProperties error.