jsonforms
jsonforms copied to clipboard
rule not validated when property is not present at all
Describe the bug
rules with the schema {const: null} don't validate successfully when the respective property doesn't exist
To Reproduce Steps to reproduce the behavior:
- check out this repo on the specific branch: https://github.com/Felix-Puetz/jsonforms-vue-example/tree/bug/const-null-returns-true-on-empty-object
- run
npm installin it - run
npm run servein it - launch the given url in your browser
Example schema:
{
type: "object",
properties: {
name: { type: "string" },
mail: { type: "string" },
},
required: ["name", "mail"],
};
Example uischema:
{
type: "VerticalLayout",
elements: [
{
scope: "#/properties/name",
type: "control",
},
{
scope: "#/properties/mail",
type: "control",
rule: {
condition: {
scope: "#/properties/name",
schema: {
const: null
},
},
effect: "DISABLE",
},
},
]
}
Expected behavior
mail field should be disabled when name is not present in data
Screenshots
Browser (please complete the following information):
- Browser all (latest release)
Used Setup (please complete the following information): All info present in my repository
Additional context spoke to @sdirix and he confirmed
I would have expected the ui schema to work. It actually works when moving the scope of the rule one level up:
{
scope: "#/properties/mail",
type: "control",
rule: {
condition: {
scope: "#",
schema: {
properties: {
name: {
const: null
}
},
},
},
effect: "DISABLE",
},
},
We need to investigate whether this is a bug, according to spec, or some implementation defined behavior which we can adjust.
