Skip to content

Commit

Permalink
Support repeatable on constraint annotation of BV
Browse files Browse the repository at this point in the history
See gh-5
  • Loading branch information
kazuki43zoo committed Feb 3, 2018
1 parent 71cbc85 commit 9add4f4
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 4 deletions.
6 changes: 2 additions & 4 deletions src/main/java/com/kazuki43zoo/app/account/PasswordForm.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,8 @@
import javax.validation.constraints.NotNull;
import java.io.Serializable;

@NotEqualsPropertyValues.List({
@NotEqualsPropertyValues(property = "password", comparingProperty = "username", message = "{NotEqualsWithAccountId.message}")
, @NotEqualsPropertyValues(property = "password", comparingProperty = "currentPassword", message = "{NotEqualsWithCurrentPassword.message}")
})
@NotEqualsPropertyValues(property = "password", comparingProperty = "username", message = "{NotEqualsWithAccountId.message}")
@NotEqualsPropertyValues(property = "password", comparingProperty = "currentPassword", message = "{NotEqualsWithCurrentPassword.message}")
@EqualsPropertyValues(property = "confirmPassword", comparingProperty = "password", message = "{EqualsWithPassword.message}")
@lombok.Data
@lombok.ToString(exclude = {"currentPassword", "password", "confirmPassword"})
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/com/kazuki43zoo/core/validation/AccountId.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import java.lang.annotation.Documented;
import java.lang.annotation.Repeatable;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;

Expand All @@ -18,6 +19,7 @@
@Retention(RUNTIME)
@NotNull
@Size(max = 128)
@Repeatable(AccountId.List.class)
public @interface AccountId {

String message() default "{com.github.kazuki43zoo.core.validation.AccountId.message}";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import javax.validation.OverridesAttribute;
import javax.validation.Payload;
import java.lang.annotation.Documented;
import java.lang.annotation.Repeatable;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;

Expand All @@ -18,6 +19,7 @@
@Target({TYPE, ANNOTATION_TYPE})
@Retention(RUNTIME)
@Compare(left = "", right = "", operator = Compare.Operator.EQUAL, message = "{com.github.kazuki43zoo.core.validation.EqualsPropertyValues.message}")
@Repeatable(EqualsPropertyValues.List.class)
public @interface EqualsPropertyValues {
@OverridesAttribute(constraint = Compare.class, name = "message")
String message() default "";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
@Retention(RUNTIME)
@NotNull
@Size(max = 128)
@Repeatable(FirstName.List.class)
public @interface FirstName {

String message() default "{com.github.kazuki43zoo.core.validation.FirstName.message}";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
@Target({METHOD, FIELD, ANNOTATION_TYPE, CONSTRUCTOR, PARAMETER})
@Retention(RUNTIME)
@Size(max = 128)
@Repeatable(LastName.List.class)
public @interface LastName {

String message() default "{com.github.kazuki43zoo.core.validation.LastName.message}";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import javax.validation.OverridesAttribute;
import javax.validation.Payload;
import java.lang.annotation.Documented;
import java.lang.annotation.Repeatable;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;

Expand All @@ -18,6 +19,7 @@
@Target({TYPE, ANNOTATION_TYPE})
@Retention(RUNTIME)
@Compare(left = "", right = "", operator = Compare.Operator.NOT_EQUAL, message = "{com.github.kazuki43zoo.core.validation.NotEqualsPropertyValues.message}")
@Repeatable(NotEqualsPropertyValues.List.class)
public @interface NotEqualsPropertyValues {
@OverridesAttribute(constraint = Compare.class, name = "message")
String message() default "";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
@Retention(RUNTIME)
@ReportAsSingleViolation
@Size(min = 8)
@Repeatable(Password.List.class)
public @interface Password {

String message() default "{com.github.kazuki43zoo.core.validation.Password.message}";
Expand Down

0 comments on commit 9add4f4

Please sign in to comment.