isRegexMatch

isRegexMatch(regex)

Verifies if provided Verificable represents a string that matches provided regex object.

Arguments:

  • regex - required, of type RegExp

Possible errors:

If provided Verificable is not a string:

{
    type: "isString",
    path: [/* ... */]
}

If provided Verificable is not matching provided regex:

{
    type: "isRegexMatch",
    path: [/* ... */]
}

Examples:

Each of examples uses this import statement:

Null or undefined is not considered a string:

Number value is not considered a string as well:

Value not matching the regex is not matching the predicate:

Value matching the regex matches the predicate:

Last updated

Was this helpful?