Description
As a developer, I expect to be able to define a schema for an array of non-empty strings, for which form validation rejects an array containing one or more empty strings.
Expected behaviour
Using the following schema:
{
"type": "object",
"properties": {
"listOfNonEmptyStrings": {
"type": "array",
"items": {
"type": "string",
"minLength": 1
}
}
},
"required": [
"listOfNonEmptyStrings"
]
}
and the following form config:
[
"*",
{
"type": "submit",
"title": "OK"
}
]
... in the generated form, leave one or more of the entries empty. I expect the form to be rendered as invalid.
Actual behaviour
Using the schema above accepts an array containing empty strings or null entries and renders the form as valid. Trying to use pattern
instead of minLength
(e.g. "pattern": "^.+$"
) has the same result. TV4 itself rejects the model.
I tried setting minLength
of 2 instead of 1, and this rejects arrays containing single-character strings, but still accepts arrays with empty strings & null entries.
Gist/Plunker/Demo
Empty string issue:
- Click Submit
- First alert says "angular-schema-form says form is valid", despite the array consisting of a single empty string.
- Second alert says "TV4 says form is not valid: String is too short (0 chars), minimum 1", which is correct.
Null entry issue:
- Delete the existing entry
- Add a new entry (and don't edit it)
- Click Submit
- First alert says "angular-schema-form says form is valid", despite the array consisting of a single
null
entry. - Second alert says "TV4 says form is not valid: Invalid type: undefined (expected string)", which is correct.
@json-schema-form/angular-schema-form-lead