No empty array values¶
noEmptyArrayValues validates that a plain object does not contain any empty arrays in its own enumerable properties.
It performs a strict structural check ensuring the value is a plain object, then inspects each property value for empty arrays. If the value is not a plain object or contains any empty arrays, the rule emits a single validation event. Otherwise, it produces no validation output.
Signature¶
Through the API:
.noEmptyArrayValues()
And internally:
export const noEmptyArrayValues: ValidationRule
(value: unknown, path: FieldPath) => Promise<ReadonlyArray<JaneEvent>>
Events¶
| Event code | Description |
|---|---|
object.not.plain-object |
Value is not a JSON-compatible plain object |
object.has.empty-array |
Object contains at least one empty array |
Design rationale¶
- Provides a strict, predictable empty array prohibition.
- First ensures the value is a plain object, then checks all property values.
- Rejects any property that has an array with zero elements.
- Useful for enforcing data quality where empty arrays should be avoided.
- 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¶
noEmptyArrayValues 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 a plain object, emits
object.not.plain-object. - If the value is a plain object but contains any empty arrays, emits
object.has.empty-array. - If the value is a plain object with no empty arrays → returns an empty result set.
Examples¶
Valid object with no empty arrays¶
await noEmptyArrayValues({ name: "John", tags: ["developer"] }, "$");
// → []
Object with empty array¶
await noEmptyArrayValues({ name: "John", tags: [] }, "$");
// → [
// JaneEvent{
// kind: "error",
// code: "object.has.empty-array",
// path: "$",
// ...
// }
// ]
Array (invalid)¶
await noEmptyArrayValues([1, 2, 3], "$");
// → [
// JaneEvent{
// kind: "error",
// code: "object.not.plain-object",
// path: "$",
// ...
// }
// ]