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