update beanvalidation templates and samples jersey2 #4719 (#4732)

This commit is contained in:
jfiala 2017-03-07 16:35:06 +01:00 committed by wing328
parent 6a7340378a
commit 2f43f98cfa
5 changed files with 30 additions and 71 deletions

View File

@ -1,53 +1,4 @@
{{#required}}
@NotNull
{{/required}}
{{#pattern}}
@Pattern(regexp="{{pattern}}")
{{/pattern}}
{{#minLength}}
{{#maxLength}}
@Size(min={{minLength}},max={{maxLength}})
{{/maxLength}}
{{/minLength}}
{{#minLength}}
{{^maxLength}}
@Size(min={{minLength}})
{{/maxLength}}
{{/minLength}}
{{^minLength}}
{{#maxLength}}
@Size(max={{maxLength}})
{{/maxLength}}
{{/minLength}}
{{#minItems}}
{{#maxItems}}
@Size(min={{minItems}},max={{maxItems}})
{{/maxItems}}
{{/minItems}}
{{#minItems}}
{{^maxItems}}
@Size(min={{minItems}})
{{/maxItems}}
{{/minItems}}
{{^minItems}}
{{#maxItems}}
@Size(max={{maxItems}})
{{/maxItems}}
{{/minItems}}
{{! check for integer / number=decimal type}}
{{#isInteger}}
{{#minimum}}
@Min({{minimum}})
{{/minimum}}
{{#maximum}}
@Max({{maximum}})
{{/maximum}}
{{/isInteger}}
{{^isInteger}}
{{#minimum}}
@DecimalMin("{{minimum}}")
{{/minimum}}
{{#maximum}}
@DecimalMax("{{maximum}}")
{{/maximum}}
{{/isInteger}}
{{>beanValidationCore}}

View File

@ -0,0 +1,20 @@
{{#pattern}} @Pattern(regexp="{{pattern}}"){{/pattern}}{{!
minLength && maxLength set
}}{{#minLength}}{{#maxLength}} @Size(min={{minLength}},max={{maxLength}}){{/maxLength}}{{/minLength}}{{!
minLength set, maxLength not
}}{{#minLength}}{{^maxLength}} @Size(min={{minLength}}){{/maxLength}}{{/minLength}}{{!
minLength not set, maxLength set
}}{{^minLength}}{{#maxLength}} @Size(max={{maxLength}}){{/maxLength}}{{/minLength}}{{!
@Size: minItems && maxItems set
}}{{#minItems}}{{#maxItems}} @Size(min={{minItems}},max={{maxItems}}){{/maxItems}}{{/minItems}}{{!
@Size: minItems set, maxItems not
}}{{#minItems}}{{^maxItems}} @Size(min={{minItems}}){{/maxItems}}{{/minItems}}{{!
@Size: minItems not set && maxItems set
}}{{^minItems}}{{#maxItems}} @Size(max={{maxItems}}){{/maxItems}}{{/minItems}}{{!
check for integer or long / all others=decimal type with @Decimal*
isInteger set
}}{{#isInteger}}{{#minimum}} @Min({{minimum}}){{/minimum}}{{#maximum}} @Max({{maximum}}){{/maximum}}{{/isInteger}}{{!
isLong set
}}{{#isLong}}{{#minimum}} @Min({{minimum}}){{/minimum}}{{#maximum}} @Max({{maximum}}){{/maximum}}{{/isLong}}{{!
Not Integer, not Long => we have a decimal value!
}}{{^isInteger}}{{^isLong}}{{#minimum}} @DecimalMin("{{minimum}}"){{/minimum}}{{#maximum}} @DecimalMax("{{maximum}}"){{/maximum}}{{/isLong}}{{/isInteger}}

View File

@ -1 +1 @@
{{! PathParam is always required, no @NotNull necessary }}{{#pattern}} @Pattern(regexp="{{pattern}}"){{/pattern}}{{#minLength}}{{#maxLength}} @Size(min={{minLength}},max={{maxLength}}){{/maxLength}}{{/minLength}}{{#minLength}}{{^maxLength}} @Size(min={{minLength}}){{/maxLength}}{{/minLength}}{{^minLength}}{{#maxLength}} @Size(max={{maxLength}}){{/maxLength}}{{/minLength}}{{#minItems}}{{#maxItems}} @Size(min={{minItems}},max={{maxItems}}){{/maxItems}}{{/minItems}}{{#minItems}}{{^maxItems}} @Size(min={{minItems}}){{/maxItems}}{{/minItems}}{{^minItems}}{{#maxItems}} @Size(max={{maxItems}}){{/maxItems}}{{/minItems}}{{#minimum}} @Min({{minimum}}){{/minimum}}{{#maximum}} @Max({{maximum}}){{/maximum}}
{{! PathParam is always required, no @NotNull necessary }}{{>beanValidationCore}}

View File

@ -1 +1 @@
{{#required}} @NotNull{{/required}}{{#pattern}} @Pattern(regexp="{{pattern}}"){{/pattern}}{{#minLength}}{{#maxLength}} @Size(min={{minLength}},max={{maxLength}}){{/maxLength}}{{/minLength}}{{#minLength}}{{^maxLength}} @Size(min={{minLength}}){{/maxLength}}{{/minLength}}{{^minLength}}{{#maxLength}} @Size(max={{maxLength}}){{/maxLength}}{{/minLength}}{{#minItems}}{{#maxItems}} @Size(min={{minItems}},max={{maxItems}}){{/maxItems}}{{/minItems}}{{#minItems}}{{^maxItems}} @Size(min={{minItems}}){{/maxItems}}{{/minItems}}{{^minItems}}{{#maxItems}} @Size(max={{maxItems}}){{/maxItems}}{{/minItems}}{{#minimum}} @Min({{minimum}}){{/minimum}}{{#maximum}} @Max({{maximum}}){{/maximum}}
{{#required}} @NotNull{{/required}}{{>beanValidationCore}}

View File

@ -80,9 +80,7 @@ public class FormatTest {
**/
@JsonProperty("integer")
@ApiModelProperty(value = "")
@Min(10)
@Max(100)
public Integer getInteger() {
@Min(10) @Max(100) public Integer getInteger() {
return integer;
}
@ -103,9 +101,7 @@ public class FormatTest {
**/
@JsonProperty("int32")
@ApiModelProperty(value = "")
@Min(20)
@Max(200)
public Integer getInt32() {
@Min(20) @Max(200) public Integer getInt32() {
return int32;
}
@ -146,9 +142,7 @@ public class FormatTest {
@JsonProperty("number")
@ApiModelProperty(required = true, value = "")
@NotNull
@DecimalMin("32.1")
@DecimalMax("543.2")
public BigDecimal getNumber() {
@DecimalMin("32.1") @DecimalMax("543.2") public BigDecimal getNumber() {
return number;
}
@ -169,9 +163,7 @@ public class FormatTest {
**/
@JsonProperty("float")
@ApiModelProperty(value = "")
@DecimalMin("54.3")
@DecimalMax("987.6")
public Float getFloat() {
@DecimalMin("54.3") @DecimalMax("987.6") public Float getFloat() {
return _float;
}
@ -192,9 +184,7 @@ public class FormatTest {
**/
@JsonProperty("double")
@ApiModelProperty(value = "")
@DecimalMin("67.8")
@DecimalMax("123.4")
public Double getDouble() {
@DecimalMin("67.8") @DecimalMax("123.4") public Double getDouble() {
return _double;
}
@ -213,8 +203,7 @@ public class FormatTest {
**/
@JsonProperty("string")
@ApiModelProperty(value = "")
@Pattern(regexp="/[a-z]/i")
public String getString() {
@Pattern(regexp="/[a-z]/i") public String getString() {
return string;
}
@ -331,8 +320,7 @@ public class FormatTest {
@JsonProperty("password")
@ApiModelProperty(required = true, value = "")
@NotNull
@Size(min=10,max=64)
public String getPassword() {
@Size(min=10,max=64) public String getPassword() {
return password;
}