Validation utils
import { isEmail, isStrongPassword } from '@gg-software/utils';All of these are format checks — they say a value looks valid, not that it exists.
isEmail
Pragmatic email check (single @, no spaces, dot in the domain).
isEmail('ada@example.com'); // true
isEmail('nope@nope'); // falseisUrl
URL check via the URL constructor, restricted to the given protocols.
isUrl('https://example.com'); // true
isUrl('example.com'); // false (no protocol)
isUrl('javascript:alert(1)'); // false (protocol not allowed)
isUrl('ftp://files.example.com', ['ftp:']); // true| Parameter | Type | Default |
|---|---|---|
value | string | — |
protocols | string[] | ['http:', 'https:'] |
isPhone
Permissive international check: optional leading +, digits with spaces / dashes / dots /
parentheses, 7–15 digits total (E.164 bounds).
isPhone('+420 601 123 456'); // true
isPhone('601123456'); // true
isPhone('12ab34'); // falseisStrongPassword
Strength check against configurable requirements.
isStrongPassword('Passw0rd'); // true (default rules)
isStrongPassword('passw0rd'); // false (no uppercase)
isStrongPassword('Sup3r$ecret', { symbol: true }); // trueDefaults (PasswordRequirements):
| Option | Default | Meaning |
|---|---|---|
minLength | 8 | minimum length |
uppercase | true | at least one A–Z |
lowercase | true | at least one a–z |
number | true | at least one digit |
symbol | false | at least one non-alphanumeric |