hasSizeEqualTo
The validatable Array must have a size equal to size when this constraint is applied.
Code example:
val validate = Validator<Array<Char>> { hasSizeEqualTo(3) }
validate(arrayOf('a', 'b', 'c')) // Success
validate(arrayOf('a', 'b')) // Failure (message: The number of items must be equal to 3)
Content copied to clipboard
The validatable Collection must have a size equal to size when this constraint is applied.
Code example:
val validate = Validator<Collection<Char>> { hasSizeEqualTo(3) }
validate(listOf('a', 'b', 'c')) // Success
validate(listOf('a', 'b')) // Failure (message: The number of items must be equal to 3)
Content copied to clipboard
The validatable Map must have a size equal to size when this constraint is applied.
Code example:
val validate = Validator<Map<Char, Int>> { hasSizeEqualTo(3) }
validate(mapOf('a' to 1, 'b' to 2, 'c' to 3)) // Success
validate(mapOf('a' to 1, 'b' to 2)) // Failure (message: The number of items must be equal to 3)
Content copied to clipboard