Skip to content

Alpha

alpha validates that a string contains only ASCII alphabetic characters (A-Z and a-z).

It enforces strict structural string validation and rejects any non-string value or string containing non-alphabetic characters. If the value is not a string or contains invalid characters, the rule emits a single validation event. Otherwise, it produces no validation output.

Signature

Through the API:

.alpha()

And internally:

export const alpha: ValidationRule
(value: unknown, path: FieldPath) => Promise<ReadonlyArray<JaneEvent>>

Events

Event code Description
type.not.valid Value is not structurally a string
string.not.alpha String contains non-alphabetic characters

Design rationale

  • Provides a strict, predictable alphabetic character validation.
  • Rejects non-string values with a clear structural-type diagnostic.
  • Uses ASCII-only character set for consistency and predictability.
  • 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 JaneEvent objects.

Invoke

alpha 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 non-alphabetic characters, emits string.not.alpha.
  • If the value is a string containing only A-Z and a-z → returns an empty result set.

Examples

Valid alphabetic string

await alpha("Hello", "$");
// → []

String with numbers

await alpha("Hello123", "$");
// → [
//     JaneEvent{
//       kind: "error",
//       code: "string.not.alpha",
//       path: "$",
//       ...
//     }
//   ]

Non-string value

await alpha(42, "$");
// → [
//     JaneEvent{
//       kind: "error",
//       code: "type.not.valid",
//       path: "$",
//       ...
//     }
//   ]