hasSizeBetween

@JvmName(name = "arrayHasSizeBetween")
fun <T> Validatable<Array<out T>?>.hasSizeBetween(range: IntRange): Constraint

The validatable Array must have a size within the provided range when this constraint is applied.

Code example:

val validate = Validator<Array<Char>> { hasSizeBetween(1..2) }
validate(emptyArray()) // Failure (message: The number of items must be between 1 and 2)
validate(arrayOf('a')) // Success
validate(arrayOf('a', 'b')) // Success
validate(arrayOf('a', 'b', 'c')) // Failure (message: The number of items must be between 1 and 2)

@JvmName(name = "collectionHasSizeBetween")
fun <T> Validatable<Collection<T>?>.hasSizeBetween(range: IntRange): Constraint

The validatable Collection must have a size within the provided range when this constraint is applied.

Code example:

val validate = Validator<Collection<Char>> { hasSizeBetween(1..2) }
validate(emptyList()) // Failure (message: The number of items must be between 1 and 2)
validate(listOf('a')) // Success
validate(listOf('a', 'b')) // Success
validate(listOf('a', 'b', 'c')) // Failure (message: The number of items must be between 1 and 2)

@JvmName(name = "mapHasSizeBetween")
fun <T> Validatable<Map<*, T>?>.hasSizeBetween(range: IntRange): Constraint

The validatable Map must have a size within the provided range when this constraint is applied.

Code example:

val validate = Validator<Map<Char, Int>> { hasSizeBetween(1..2) }
validate(emptyMap()) // Failure (message: The number of items must be between 1 and 2)
validate(mapOf('a' to 1)) // Success
validate(mapOf('a' to 1, 'b' to 2)) // Success
validate(mapOf('a' to 1, 'b' to 2, 'c' to 3)) // Failure (message: The number of items must be between 1 and 2)