Skip to content

Require all

requireAll enforces that every specified field must be present and accepted. If any field is missing or rejected, the rule emits a boundary‑level error for each offending key.

This rule is ideal for mandatory groups of fields, minimum‑shape guarantees, and any scenario where all listed fields must be provided together.

Signature

export function requireAll(...keys: string[]): BoundaryRule

Parameters

Parameter Data type Description
keys string[] The fields that must all be present and accepted.

Events

Event code Description
boundary.does.require-all A required field was missing or not accepted.

Design rationale

  • Enforces complete presence of a field set.
  • Emits one error per missing or rejected field, ensuring precise contributor feedback.
  • Evaluates required fields strictly by acceptance (decision.code === "accept").
  • Does not modify field values or decisions — it only adds boundary‑level issues.
  • Ideal for shapes where partial data is invalid or incomplete.

Invoke

requireAll runs during the boundary decision phase. It is not affected by normalization mode or parsing rules.

The rule activates when:

  • Any of the specified fields are missing.
  • Any of the specified fields exist but are not accepted.

Examples

Valid: all fields accepted

requireAll("street", "city", "zip");

// street accepted
// city accepted
// zip accepted
// → OK (no boundary issues)

Invalid: missing or rejected fields

requireAll("street", "city", "zip");

// street accepted
// city missing
// zip rejected
// → boundary.does.require-all at $.city
// → boundary.does.require-all at $.zip

Empty or partial input — rule enforces completeness

requireAll("a", "b");

// fields = { a }
// → boundary.does.require-all at $.b