-
Notifications
You must be signed in to change notification settings - Fork 19
Closed
Description
Problem
The following example is about description, but this happens with any conditional attribute (title, minimum, etc).
Given a form that asks for two fields is_full_time (yes/no) and hours (number). If yes is selected, then it shows a description warning about the maximum hours.
The JSON Schema is the following:
{
"properties": {
"is_full_time": {
"type": "string",
"title": "Is full time",
"oneOf": [{ "const": "yes", "title": "Yes" }, { "const": "no", "title": "No" }]
},
"hours": { "type": "number", "title": "Hours per day" }
},
"allOf": [
{
"if": {
"properties": { "is_full_time": { "const": "yes" } },
"required": ["is_full_time"]
},
"then": {
"properties": {
"hours": {
"description": "We recommend no more than 8 hours."
}
}
}
}
]
}Steps to reproduce:
- In the playground add the schema above.
- Select Yes, the description shows up.
- Select No. The description should disappear but it remains 🐛
For this scenario, a workaround could be to undo the value by set description: "" in the else statement, like this:
"else": {
"properties": {
"hours": {
"description": ""
}
}
}
But this ain't possible for every attribute. For example, if you set const: 10, there's no way to "undo" it. Same for any other type of validation.
Metadata
Metadata
Assignees
Labels
No labels