mtedone / podam

PODAM - POjo DAta Mocker
https://mtedone.github.io/podam
MIT License
323 stars 750 forks source link

Using @javax.validation.constraints.Size with only max contraint may result in an empty string #244

Closed hfcipriano closed 7 years ago

hfcipriano commented 7 years ago
Class A {
    @Size(max = 4)
    @NotEmpty()
    String b;
    get set...
}

A result = podam.manufacturePojo(A.class);

In some invokes the b attribute has the value "" (Empty) what is invalid

Sorry for the previously equivocated question

hfcipriano commented 7 years ago

If i use just only NotEmpty or Size it's works perfectly but i need to define a String not empty with at most 4 characteres

daivanov commented 7 years ago

Thus, @Size(min = 1, max = 4) is not an option?

hfcipriano commented 7 years ago

Not because i would to differentiate messages when the user input a empty string and when user input max lenght string..

@Size(max = 4, message = "max.limitation")
@NotEmpty(message="not.empty")
hfcipriano commented 7 years ago

I commented into changeset

What i'm saying is that sometimes the generated value is correct and another times the value is "" (Empty string)

If you re-run this test a few times, you'll see that in some of them the value will be "" (Empty String)

daivanov commented 7 years ago

Released in podam 7.1.0