Skip to content

endsWith ​

The string ends with value.

Signature ​

ts
function endsWith(value: string, msg?: Message): Action<string>

Parameters ​

ParameterTypeDescription
valuestringThe substring
msgMessageCustom error message

Error codes ​

CodeWhenDefault message
endsWithThe condition is not metMust 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 ​