No null values¶
noNullValues validates that a plain object does not contain any null values in its own enumerable properties.
It performs a strict structural check ensuring the value is a plain object, then inspects each property value for null. If the value is not a plain object or contains any null values, the rule emits a single validation event. Otherwise, it produces no validation output.
Signature¶
Through the API:
.noNullValues()
And internally:
export const noNullValues: 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.null-value |
Object contains at least one null value |
Design rationale¶
- Provides a strict, predictable null value prohibition.
- First ensures the value is a plain object, then checks all property values.
- Rejects any property that has exactly the
nullvalue. - Useful for enforcing strict data quality where nulls are not allowed.
- 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¶
noNullValues 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 null values, emits
object.has.null-value. - If the value is a plain object with no null values → returns an empty result set.
Examples¶
Valid object with no null values¶
await noNullValues({ name: "John", age: 30 }, "$");
// → []
Object with null value¶
await noNullValues({ name: "John", age: null }, "$");
// → [
// JaneEvent{
// kind: "error",
// code: "object.has.null-value",
// path: "$",
// ...
// }
// ]
Array (invalid)¶
await noNullValues([1, 2, 3], "$");
// → [
// JaneEvent{
// kind: "error",
// code: "object.not.plain-object",
// path: "$",
// ...
// }
// ]