Skip to content

Commit

Permalink
Change from stopAfterFoundFirstInvalidField to failFast
Browse files Browse the repository at this point in the history
  • Loading branch information
yasuyuki-baba-2 committed May 22, 2017
1 parent 6bf1aa3 commit 50db45a
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public class CommonEachValidator implements ConstraintValidator<Annotation, Coll
private boolean earlyInterpolation;

// after initialization it's read-only
private boolean stopAfterFoundFirstInvalidField = true;
private boolean failFast = true;

public void initialize(Annotation eachAnnotation) {

Expand All @@ -98,7 +98,7 @@ public void initialize(Annotation eachAnnotation) {
ConstraintDescriptor descriptor = createConstraintDescriptor(constraint);

descriptors = unmodifiableList(asList(descriptor));
stopAfterFoundFirstInvalidField = eachConstraint.stopAfterFoundFirstInvalidField();
failFast = eachConstraint.failFast();

// legacy and deprecated, will be removed in next major version!
} else if (isWrapperAnnotation(eachAType)) {
Expand Down Expand Up @@ -157,7 +157,7 @@ public boolean isValid(Collection<?> collection, ConstraintValidatorContext cont
: readAttribute(descriptor.getAnnotation(), "message", String.class);

addConstraintViolationInIterable(context, message, index);
if (stopAfterFoundFirstInvalidField) {
if (failFast) {
return false;
}
valid = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,5 +51,5 @@
/**
* Indicates whether stop the validation after first invalid field found.
*/
boolean stopAfterFoundFirstInvalidField() default true;
boolean failFast() default true;
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
@Documented
@Retention(RUNTIME)
@Target({METHOD, FIELD, ANNOTATION_TYPE})
@EachConstraint(validateAs = NotNull.class, stopAfterFoundFirstInvalidField = false)
@EachConstraint(validateAs = NotNull.class, failFast = false)
@Constraint(validatedBy = CommonEachValidator.class)
public @interface EachNotNullAll {

Expand Down

0 comments on commit 50db45a

Please sign in to comment.