Question: why is the `@Validate` annotation needed...
# akkurate
c
Question: why is the
@Validate
annotation needed?
j
Hi @Cies! The annotation allows the compiler plugin to know for which classes it should generate accessors. Take this example:
Copy code
@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.