yavi
yavi copied to clipboard
Support Bean Validation Annotations via Annotation Processor to generate a Validator
public class Message {
@NotEmpty
private String text;
public String getText() {
return text;
}
public void setText(String text) {
this.text = text;
}
}
↓
import am.ik.yavi.builder.ValidatorBuilder;
import am.ik.yavi.core.Validator;
public class Message_Validator {
public static final Validator<Message> INSTANCE = ValidatorBuilder.<Message>of()
.constraint(Message::getText, "text", c -> c.notEmpty())
.build();
}
I have written a few annotation processors and had something like this in mind. Is there a branch or separate repo where a prototype for this is located? Looking for help?
@rbygrave https://github.com/making/yavi/tree/beanvalidation here it is. It’s a naive implementation. Nested constraints (@ Valid) are not supported yet
Ah, it is in the same module - not a separate module. I was not expecting that. I guess I was also thinking about this as a potential drop in implementation for the standard BeanValidation Validator API which is perhaps a subtly different goal.
It is now implemented as a Poc in the same repository. I think it will be another repository eventually.
I guess I was also thinking about this as a potential drop in implementation for the standard BeanValidation
It would be great if the base part can be reusable :)