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 Feb 23, 2024
1 parent 2eeb7e7 commit 35220d1
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 @@ -247,6 +247,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 All @@ -262,7 +267,8 @@ export function validateConfig(schema, config) {
*
* @template {object} Config
* @typedef {object} Schema
* @property {SchemaCondition<Config>[]} [anyOf] - List of schema conditions
* @property {SchemaCondition<Config>[]} [allOf] - List of schema conditions, all must pass
* @property {SchemaCondition<Config>[]} [anyOf] - List of schema conditions, any must pass
*/

/**
Expand Down

0 comments on commit 35220d1

Please sign in to comment.