endsWith
The string ends with value.
Signature
ts
function endsWith(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 |
|---|---|---|
endsWith | The condition is not met | Must end 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(), email(), endsWith('@company.com', 'Only corporate email'))See also
- pattern — complex conditions