Binder validation error dont show on field

I create on binder and in a specify field I put a validator:

binder.forField(numeroAto).asRequired(Utils.CAMPO_OBRIGATORIO)
                .withValidator(valor -> valor == this.indexAto,"Sequencial do ato inválido")
                .bind(MatriculaItemRetornoAto::getNumeroAto, MatriculaItemRetornoAto::setNumeroAto);

But when I execute the

binder.validate().isOk()

and the condition are not correctly (Return FALSE)

the binder return false (so its not OK) but the field does not change to the red border.

tks

Is your error message shown? If not: the validation did not trigger.

No… the message don`t show. but if I debug and look for the errors. the errors show

Can you post the full field instantiation and e.g. called setters on it? Might be related to some field methods like setMaxLength

Sure… I dont do anything diff.

my field instantiation

IntegerField numeroAto = new IntegerField("Numero");
        numeroAto.setMinWidth("70px");

my binder instantiation

protected Binder<T> binder = new Binder();

my binder with the field

binder.forField(numeroAto).asRequired(Utils.CAMPO_OBRIGATORIO)
                .withValidator(valor -> valor == this.indexAto,"Sequencial do ato inválido")
                .bind(MatriculaItemRetornoAto::getNumeroAto, MatriculaItemRetornoAto::setNumeroAto);

my getter and setter are generated by lombok
my field

private Integer numeroAto;

and my validation

return binder.validate().isOk()

like I said, the binder.validate().isOk() return false, and if I loop through the errors return that error I sended at image

Just to verify, because I haven’t seen it misbehave like this in the past…

  • did you try another field… e.g. like text field?
  • did you use set/read bean?

With an TextField works fine:

image

at the image the field teste and field Numero are wrong… but only in the field teste the border are red and has a error message. with the NumberField the border dont works

@sissbruecker you happen to know some quirks with the number field? It looks buggy but haven’t used it :grimacing:

I know about this bug… but (at least in the past) required to have min/max value applied IntegerField / AbstractNumberField: Validation for Min/Max has no message / prevents custom validation · Issue #6055 · vaadin/flow-components · GitHub

Not related to the problem, but be aware that comparing boxed Integer with == will probably result in unexpected outcomes, if the value is greater than 128

so. how Is the problem?

System.out.println("17 == 17 ?" + (Integer.valueOf(17) == Integer.valueOf(17)));
System.out.println("130 == 130 ? " + (Integer.valueOf(130) == Integer.valueOf(130)));

prints

17 == 17 ?true
130 == 130 ? false

Integer values between -128 and 127 are cached into an internal IntegerCache

Ok…
Now I change the code:


binder.forField(numeroAto).asRequired(Utils.CAMPO_OBRIGATORIO)
                .withValidator(valor -> this.indexAto.equals(valor),"Sequencial do ato inválido")

but still not working as expected

and the screen
image