koumoul-dev / vuetify-jsonschema-form

Create beautiful and low-effort forms that output valid data. Published on npm as @koumoul/vjsf.
https://koumoul-dev.github.io/vuetify-jsonschema-form/latest/
MIT License
538 stars 154 forks source link

Multiple types combined with pattern can break validation #369

Open jakobsa opened 1 year ago

jakobsa commented 1 year ago

Given:

{
    type: 'object',
    properties: {
        anyProp: {
            "type": [
                              "string",
                              "boolean"
                          ],
                          "pattern": "^[^${}]+$",
                          "default": true
        }
    }
}

Expected result:

validation ok, and {anyProp: true}

Actual result:

TypeError: e.match is not a function

Analysis: when applying validation rules, string is expected but other type (in this case: boolean) is given.

albanm commented 1 year ago

What does json-schema say about that ? Are you sure a validator like ajv will ever accept a boolean value, or will it always estimate that it fails the pattern rule ?

jakobsa commented 1 year ago

https://www.jsonschemavalidator.net/s/O7JdN2OS is fine with it.