No space¶
noSpace validates that a string contains no whitespace characters (spaces, tabs, newlines, etc.).
It enforces strict structural string validation and rejects any non-string value or string containing any whitespace. If the value is not a string or contains whitespace, the rule emits a single validation event. Otherwise, it produces no validation output.
Signature¶
Through the API:
.noSpace()
And internally:
export const noSpace: ValidationRule
(value: unknown, path: FieldPath) => Promise<ReadonlyArray<JaneEvent>>
Events¶
| Event code | Description |
|---|---|
type.not.valid |
Value is not structurally a string |
string.has.whitespace |
String contains whitespace characters |
Design rationale¶
- Provides a strict, predictable whitespace-free string validation.
- Rejects non-string 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¶
noSpace 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 string, emits
type.not.valid. - If the value is a string but contains whitespace, emits
string.has.whitespace. - If the value is a string with no whitespace → returns an empty result set.
Examples¶
Valid string with no whitespace¶
await noSpace("hello", "$");
// → []
String with spaces¶
await noSpace("hello world", "$");
// → [
// JaneEvent{
// kind: "error",
// code: "string.has.whitespace",
// path: "$",
// ...
// }
// ]
Non-string value¶
await noSpace(42, "$");
// → [
// JaneEvent{
// kind: "error",
// code: "type.not.valid",
// path: "$",
// ...
// }
// ]