pattern

fun StringRuleBuilder.pattern(pattern: String, message: () -> String)

Validates that the string matches the pattern.

Usage:

rules<String> {
pattern("^[A-Za-z]+$") { "must be alphabetic" }
}

Parameters

pattern

The regular expression pattern the string must match.

message

The message to return when the test fails.


fun StringRuleBuilder.pattern(pattern: Regex, message: () -> String)

Validates that the string matches the pattern.

Usage:

rules<String> {
pattern(Regex("^[A-Za-z]+$")) { "must be alphabetic" }
}

Parameters

pattern

The regular expression pattern the string must match.

message

The message to return when the test fails.