Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix ConditionalHandler value checks #196

Closed
elbakerino opened this issue Jul 27, 2022 · 1 comment
Closed

Fix ConditionalHandler value checks #196

elbakerino opened this issue Jul 27, 2022 · 1 comment
Labels
bug Something isn't working core json-schema-spec Relates to official JSON-Schema Spec. validators
Projects

Comments

@elbakerino
Copy link
Member

elbakerino commented Jul 27, 2022

Current Behavior

Currently the ConditionalHandler fails to validate nested objects - if there are no default values inside of the nested object. Thus some else will never be applied, as the if is never evaluated.

Expected Behavior

Not checking for existance of object - and also evaluating it for other types than for object.

Steps to Reproduce

e.g. in this schema the if/then/else is not evaluated without the default for the boolean, the default creates the parent object in the store values and only than it works as expected:

const schema = {
    type: 'object',
    properties: {
        file: {
            type: 'string',
            widget: 'FileUpload',
        },
        name: {
            type: 'object',
            properties: {
                value: {
                    type: 'string',
                    title: 'Name',
                    view: {
                        sizeMd: 10,
                    },
                },
                custom: {
                    type: 'boolean',
                    default: false, // if this `default` does not exist, the `else` will not be applied
                },
            },
            allOf: [
                {
                    if: {
                        properties: {
                            custom: {
                                const: true,
                            },
                        },
                    },
                    then: {
                        properties: {
                            value: {},
                        },
                    },
                    else: {
                        properties: {
                            value: {
                                widget: 'Select',
                                enum: ['steel', 'metal', 'earth'],
                            },
                        },
                    },
                },
            ],
        },
    },
}

For non object this is valid, but not evaluated at all currently:

{
  "type": "integer",
  "if": {
    "minimum": 4
  },
  "then": {
    "multipleOf": 2
  }
}

Your Environment

Tech Version
UI-Schema v0.4.3
@elbakerino elbakerino added bug Something isn't working json-schema-spec Relates to official JSON-Schema Spec. validators core labels Jul 27, 2022
@elbakerino elbakerino added this to To do in ui-schema via automation Jul 27, 2022
@elbakerino
Copy link
Member Author

Released with ui-schema@0.4.4

ui-schema automation moved this from To do to Done Sep 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working core json-schema-spec Relates to official JSON-Schema Spec. validators
Projects
ui-schema
  
Done
Development

No branches or pull requests

1 participant