feat(json-schema-2020-12): add support for dependentRequired keyword (#8633)

Refs #8513
This commit is contained in:
Vladimír Gorej
2023-05-08 15:13:23 +02:00
committed by GitHub
parent 03a561f1d9
commit ee868aa7ea
10 changed files with 276 additions and 173 deletions

View File

@@ -294,3 +294,18 @@ export const stringifyConstraints = (schema) => {
return constraints
}
export const getDependentRequired = (propertyName, schema) => {
if (!schema?.dependentRequired) return []
return Array.from(
Object.entries(schema.dependentRequired).reduce((acc, [prop, list]) => {
if (!Array.isArray(list)) return acc
if (!list.includes(propertyName)) return acc
acc.add(prop)
return acc
}, new Set())
)
}