-
Notifications
You must be signed in to change notification settings - Fork 234
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bean validation's @Size does not work with collections #348
Comments
Where do you see that? |
Hmm I used it on |
It looks like only the import java.util.List;
import javax.validation.constraints.Size;
import io.github.benas.randombeans.EnhancedRandomBuilder;
import io.github.benas.randombeans.api.EnhancedRandom;
import org.junit.Assert;
import org.junit.Test;
public class Issue348 {
@Test
public void testSizeOnList() {
// given
EnhancedRandom enhancedRandom = new EnhancedRandomBuilder()
.build();
// when
Person person = enhancedRandom.nextObject(Person.class);
// then
Assert.assertNotNull(person);
int size = person.getNames().size();
Assert.assertTrue(size >= 2 && size <= 5);
}
static class Person {
@Size(min = 2, max = 5)
private List<String> names;
public Person() {
}
public List<String> getNames() {
return names;
}
public void setNames(List<String> names) {
this.names = names;
}
}
} We need to add support for all types as documented in the annotation ( Thank you for reporting this issue! |
Maybe use |
Yes as I said here:
|
Size
@magx2 A fix has been deployed in version If you don't know how to use a snapshot version, please refer to the wiki here. As you might have noticed, the project has been renamed and you would need to adjust a couple of things (see migration guide). Looking forward for your feedback. Thank you upfront! |
It's working! Thanks! |
I see that you do not support annotation
javax.validation.constraints.Size
. Can you support it?From java doc:
The text was updated successfully, but these errors were encountered: