You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
group-array with required parent fails for empty array, despite minItems: 0 #247
Description:
I’m using remotess json-schema-form in my vue project. The schema I created has a parent array property ("inputType": "group-array") which is required, but the array itself can be empty (minItems: 0).
Problem:
When I validate the following json: {"sources":[]} it always says {"sources":"Required field"} and the problem is only gone, when I remove the "required": [
"sources"
]
I added a small vue example showing my issue, I would appreciate every bit of help.
Hi @mariada-ta! That's indeed a bug. We currently don't have bandwidth to fix but, could you give it a try? It's somewhere in the validateSchema function
I looked into the problem and would have fixed it like this:
File: src/validation/schema.ts
Line: 241 - 263
if (schema.required && isObjectValue(value)) {
const missingKeys = schema.required.filter((key: string) => {
const fieldValue = value[key]
const fieldSchema = schema.properties?.[key]
// Field is considered missing if:
// - it's undefined OR
// - it's null AND treatNullAsUndefined option is true
// - it's an array/object and it's empty
if (Array.isArray(fieldValue)) {
if (fieldSchema && getSchemaType(fieldSchema) === 'array') {
const minItems = (fieldSchema as any).minItems ?? 0
return fieldValue.length < minItems
}
return fieldValue.length === 0
}
if (isObjectValue(fieldValue)) {
return Object.keys(fieldValue).length === 0
}
return fieldValue === undefined || (fieldValue === null && options.treatNullAsUndefined)
})
I added a check that looks to see if there is a minItems attribute in the property and, if so, whether the element meets the length requirement. This means that an empty array with minItems: 0 is now correct.
Hi
I'd like to take a crack at this one. I see @mariada-ta proposed a fix back in January but there's no PR open yet. @mariada-ta are you still working on it? If not, I'll pick it up. My plan is to fix the required check in validateSchema so an empty array no longer counts as a missing field (array length should be governed by minItems/maxItems, not required), and add tests covering the group-array + minItems: 0 case from the issue.
Activity
sandrina-p commentedon Jan 16, 2026
Hi @mariada-ta! That's indeed a bug. We currently don't have bandwidth to fix but, could you give it a try? It's somewhere in the validateSchema function
mariada-ta commentedon Jan 22, 2026
I looked into the problem and would have fixed it like this:
File: src/validation/schema.ts
Line: 241 - 263
I added a check that looks to see if there is a minItems attribute in the property and, if so, whether the element meets the length requirement. This means that an empty array with minItems: 0 is now correct.
spiderocious commentedon May 26, 2026
Hi
I'd like to take a crack at this one. I see @mariada-ta proposed a fix back in January but there's no PR open yet. @mariada-ta are you still working on it? If not, I'll pick it up. My plan is to fix the required check in validateSchema so an empty array no longer counts as a missing field (array length should be governed by minItems/maxItems, not required), and add tests covering the group-array + minItems: 0 case from the issue.