Is email strict¶
isEmailStrict validates that a value is a strict RFC‑style email address.
It enforces a detailed pattern for both the local part and domain, rejecting malformed, ambiguous, or loosely formatted email strings. Any non‑string value or string that fails the strict pattern results in a single validation event. Otherwise, it produces no validation output.
Signature¶
Through the API:
.isEmailStrict();
And internally:
export const isEmailStrict: ValidationRule
(value: unknown, path: FieldPath) => Promise<ReadonlyArray<JaneEvent>>
Events¶
| Event code | Description |
|---|---|
type.not.valid |
Value is not a string. |
string.not.strict-email |
String does not match the strict RFC‑style pattern. |
Design rationale¶
- Enforces a stricter pattern than general‑purpose email validators.
- Rejects non‑string values early with a structural‑type diagnostic.
- Ensures both local part and domain follow RFC‑style constraints.
- Avoids normalization — contributors must provide canonical email strings.
- Emits exactly one event per failure for clarity and composability.
- Pure, total, async‑compatible, and returns a readonly array of
JaneEventobjects. - Preserves the provided path and supports pipeline‑level
userMessageoverrides.
Invoke
isEmailStrict 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 string does not match the strict regex:
/^[a-zA-Z0-9.!#$%&'*+/=?^_{|}~-]+@[a-zA-Z0-9-]+(?:.[a-zA-Z0-9-]+)+$/, → emitsstring.not.strict-email. - Otherwise, returns an empty result set.
Examples¶
Valid — strict RFC‑style email addresses¶
await isEmailStrict("user@example.com", "$");
// → []
await isEmailStrict("john.doe+tag@sub.domain.org", "$");
// → []
Invalid — non‑string values¶
await isEmailStrict(123, "$");
// → [
// JaneEvent{
// kind: "error",
// code: "type.not.valid",
// path: "$",
// ...
// }
// ]
Invalid — incorrect format¶
await isEmailStrict("user@", "$");
// → [
// JaneEvent{
// kind: "error",
// code: "string.not.strict-email",
// path: "$",
// ...
// }
// ]
await isEmailStrict("user@domain", "$"); // missing TLD
// → [
// JaneEvent{
// kind: "error",
// code: "string.not.strict-email",
// path: "$",
// ...
// }
// ]