Thursday, February 28, 2019

Possible validation bug

I created an issue in github for an possible validation related bug.


I'm trying to get hibernate-validator 6.0.X to work and have run into an issue and am not sure if what I'm seeing in the GWT codebase is a bug or not.

I'm using Validator.validateValue(...) in my tests and have encountered a bug where constraints on collections aren't being enforced. For example, I have:

public class Foo {
   
@NotEmpty List<String> strings;
}


 If 'strings' is set to Collections.emptyList() I should get a violation and I do when I call Validator.validate(obj) and Validator.validateProperty(obj, "strings") but not when I call Validator.validateValue(Foo.class, "strings", Collections.emptyList()).

The reason comes down to this snippet at line 2040 of com.google.gwt.validation.rebind.GwtSpecificValidatorCreator:

if (!isIterableOrMap(property.getElementClass())) {
    writeValidatePropertyCall(sw, property, true, false);
}

The call to writeValidatePropertyCall is only conditional in the Validator.validateValue(...) path.

There seem to be a lot of hidden gotchas with GWT so I'm wondering if there is a reason for the conditional to be there or if it's safe to remove it. I have removed it in my local code and my tests pass just fine but I'm concerned about unintended consequences.

--
You received this message because you are subscribed to the Google Groups "GWT Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscribe@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at https://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment