Skip to content

startsWith ​

The string starts with value.

Signature ​

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

Parameters ​

ParameterTypeDescription
valuestringThe substring
msgMessageCustom error message

Error codes ​

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