maxLength

fun StringRuleBuilder.maxLength(limit: Int, message: () -> String)

Validates that the string length is no more than limit characters.

Usage:

rules<String> {
maxLength(20) { "must be at no more 20 characters" }
}

Parameters

limit

The maximum number of characters the string can have.

message

The message to return when the test fails.