Mutually exclusive¶
mutuallyExclusive enforces that two fields cannot both be accepted.
If both fields resolve to accepted values, the rule emits a boundary‑level error indicating the conflict. This rule is ideal for binary exclusivity constraints — for example, “use A or B, but never both.”
Signature¶
export function mutuallyExclusive(a: string, b: string): BoundaryRule
Parameters¶
| Parameter | Data type | Description |
|---|---|---|
a |
string |
The first field that participates in the exclusion rule. |
b |
string |
The second field that participates in the exclusion rule. |
Events¶
| Event code | Description |
|---|---|
boundary.does.mutual-exclusion |
Both fields were accepted, violating exclusivity. |
Design rationale¶
- Activates only when both fields have a decision code of accept.
- Emits a single boundary‑level error describing the exclusivity violation.
- Does not modify field values or decisions — it only adds boundary‑level issues.
- Keeps contributor expectations clear by enforcing explicit binary exclusivity.
Invoke¶
mutuallyExclusive runs during the boundary decision phase. It is not affected by normalization mode or parsing rules.
The rule activates when:
fields[a]?.decision.code === "accept"fields[b]?.decision.code === "accept"
Examples¶
Valid: only one field accepted¶
mutuallyExclusive("email", "phone");
// email accepted, phone absent → OK
// phone accepted, email absent → OK
// neither accepted → OK
Invalid: both fields accepted¶
mutuallyExclusive("email", "phone");
// email accepted
// phone accepted
// → boundary.does.mutual-exclusion at $