podam icon indicating copy to clipboard operation
podam copied to clipboard

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

Open hfcipriano opened this issue 9 years ago • 5 comments

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 avatar Jul 05 '17 21:07 hfcipriano

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

hfcipriano avatar Jul 06 '17 14:07 hfcipriano

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

daivanov avatar Jul 06 '17 14:07 daivanov

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 avatar Jul 06 '17 15:07 hfcipriano

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)

hfcipriano avatar Jul 06 '17 16:07 hfcipriano

Released in podam 7.1.0

daivanov avatar Jul 25 '17 10:07 daivanov