StringLengthValidator

open class StringLengthValidator(minLength: Int, maxLength: Int = Int.MAX_VALUE) : Validator<String>

Base for string-length validators: the value's length must be in minLength..maxLength.

@Validate can only reference object validators, so subclass with concrete arguments:

object UsernameLengthValidator : StringLengthValidator(minLength = 3, maxLength = 20)

Constructors

Link copied to clipboard
constructor(minLength: Int, maxLength: Int = Int.MAX_VALUE)

Properties

Link copied to clipboard

Functions

Link copied to clipboard
open override fun validate(value: String): String?

Returns null if value is valid, or a human-readable reason string if invalid.