Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #34663
| Newsgroups | comp.lang.java.programmer |
|---|---|
| Date | 2016-06-16 14:25 -0700 |
| References | <8760t97jjm.fsf@Equus.decebal.nl> |
| Message-ID | <78c4568b-e52f-43e2-8027-a4fefa3a00b0@googlegroups.com> (permalink) |
| Subject | Re: Problem with validation |
| From | Lew <lewbloch@gmail.com> |
Cecil Westerhof wrote:
> We have a strange problem with validation. We defined the following
> annotation:
> @Documented
> @Constraint(validatedBy = {})
> @Target({ FIELD })
> @Retention(RUNTIME)
> @ReportAsSingleViolation
> @NotNull
> @Size(min = 1)
> public @interface NotEmpty {
> // default
> final static String errorMessage = "Field is not allowed to be empty";
>
> Class<?>[] groups() default {};
>
> String message() default errorMessage;
>
> Class<? extends Payload>[] payload() default {};
> }
>
> We have this annotation defined on 8 fields, like:
> @NotEmpty(message = "ZIP-code is not allowed to be empty")
>
> Only one field (the one with the ZIP-code) is empty, but when we call
> persist we get a validation exception of five of them. When we print
> the name of the field, the message and the invalid value, we see it is
> the NotEmpty annotation that fired and that except for ZIP-code the
> fields are filled. ZIP-code contains the empty string.
>
> Also when we fill ZIP-code the persist does not fire with an
> validation exception.
>
> What could be the reason we get a validation exception for four fields
> we should not get one for?
Can you please prepare an SSCCE (Simple, Self-Contained, Compilable Example), per http://sscce.org/ ?
--
Lew
Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Find similar | Unroll thread
Problem with validation Cecil Westerhof <Cecil@decebal.nl> - 2016-06-16 08:08 +0200 Re: Problem with validation Lew <lewbloch@gmail.com> - 2016-06-16 14:25 -0700
csiph-web