A constant oneOf or anyOf starts from the constant its object's default names
Detect
- In your schema: a property whose
oneOforanyOflists constants, with nodefaultof its own, inside an object whosedefaultnames one of those constants for it. - In your form data: no value for that property.
Change
Such a property started from the first constant, and now starts from the one its object's default names, as an enum does (#5895). With this schema and no formData, the result was { "n": 3 } and is now { "n": 4 }:
{
"type": "object",
"default": { "n": 4 },
"properties": { "n": { "type": "number", "oneOf": [{ "const": 3 }, { "const": 4 }] } }
}
An inherited default that names none of the constants is taken as it is, as A constant oneOf or anyOf starts from a default outside its constants describes.
To start from the first constant again, give the property that constant as its default:
-"n": { "type": "number", "oneOf": [{ "const": 3 }, { "const": 4 }] }
+"n": { "type": "number", "default": 3, "oneOf": [{ "const": 3 }, { "const": 4 }] }
Verify
- The property starts from the constant you expect when the form has no data for it.
Also read: