startsWith
The string starts with value.
Signature
ts
function startsWith(value: string, msg?: Message): Action<string>Parameters
| Parameter | Type | Description |
|---|---|---|
value | string | The substring |
msg | Message | Custom error message |
Error codes
| Code | When | Default message |
|---|---|---|
startsWith | The condition is not met | Must start with "{value}" |
You can change the texts: see Messages & i18n.
Notes
Case-sensitive. To ignore case, add toLowerCase before the rule.
Example
ts
pipe(string(), startsWith('+7'))See also
- pattern — complex conditions