Im trying to validate Date Field but I found examples only for a text field. How can I write a validator where I can check if the LocalDate is fdfempty or not?
I started with something like that:
@Override
public void setConfiguration(EditorConfiguration editorConfiguration) {
boolean required = ((DateFieldConfiguration) editorConfiguration).isRequired();
if (required == true) {
setRequiredIndicatorVisible(true);
addValueChangeListener(event -> validate(event.getSource().getDefaultValidator(), event.getValue()));
}
}
private void validate(Validator<LocalDate> defaultValidator, LocalDate localDate) {
binder.forField(this).withValidator(validator)
.asRequired("Mandatory").bind(s -> getValue(), (b, v) -> setValue(v));
}