Skip to content

Commit

Permalink
Support component config schema allOf condition
Browse files Browse the repository at this point in the history
  • Loading branch information
colinrotherham committed Mar 8, 2024
1 parent 4a40d63 commit a94a414
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion packages/govuk-frontend/src/govuk/common/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,11 @@ export function validateConfig(schema, config) {
}
}

// Check all conditions pass or add errors
if (name === 'allOf' && errors.length) {
validationErrors.push(...errors)
}

// Check one condition passes or add errors
if (name === 'anyOf' && !(conditions.length - errors.length >= 1)) {
validationErrors.push(...errors)
Expand Down Expand Up @@ -271,7 +276,8 @@ function isObject(option) {
*
* @typedef {object} Schema
* @property {{ [field: string]: SchemaProperty | undefined }} properties - Schema properties
* @property {SchemaCondition[]} [anyOf] - List of schema conditions
* @property {SchemaCondition[]} [allOf] - List of schema conditions, all must pass
* @property {SchemaCondition[]} [anyOf] - List of schema conditions, any must pass
*/

/**
Expand Down

0 comments on commit a94a414

Please sign in to comment.