Cies
05/28/2025, 2:01 PM@Validate
annotation needed?Johann Pardanaud
06/07/2025, 8:57 AM@Validate
data class Book(val title: String)
Validator<Book> { // this: Validatable<Book>
title.hasLengthLowerThan(50)
}
When you call title
inside the validator lambda, you don't get an instance of String
but an instance of Validatable<String>
, which allows to call new methods like hasLengthLowerThan
.
The fact that you get this string type wrapped in a Validatable
is due to the annotation.