Array¶
array validates that a value is structurally an array according to JavaScript semantics.
It performs a strict structural type check and rejects any non‑array value. If the value is not an array, the rule emits a single validation event. Otherwise, it produces no validation output.
Signature¶
Through the API:
.array()
And internally:
export const array: ValidationRule
(value: unknown, path: FieldPath) => Promise<ReadonlyArray<JaneEvent>>
Events¶
| Event code | Description |
|---|---|
array.not.array |
Value is not structurally an array |
Design rationale¶
- Provides a strict, predictable structural array check.
- Rejects non‑array values with a clear structural‑type diagnostic.
- Never coerces or normalizes — validation is explicit and opt‑in.
- Emits exactly one event per failure for clarity and composability.
- Async‑compatible and returns a readonly array of
JaneEventobjects.
Invoke¶
array runs only when explicitly included in a boundary or pipeline. It does not run automatically.
The rule activates when:
- The value is any JavaScript value.
- If the value is not an array, emits
array.not.array. - If the value is an array → returns an empty result set.
Examples¶
Valid array¶
await array([1, 2, 3], "$");
// → []
Non‑array value¶
await array("not-an-array", "$");
// → [
// JaneEvent{
// kind: "error",
// code: "array.not.array",
// path: "$",
// ...
// }
// ]