maxLength

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

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

Usage:

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

Parameters

limit

The maximum number of characters the CharSequence can have.

message

The message to return when the test fails.


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

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.