add check for isInteger (integer/decimal)

This commit is contained in:
J. Fiala
2017-01-06 16:46:59 +01:00
parent 24f486164a
commit 6b17b92bb6
3 changed files with 36 additions and 25 deletions

View File

@@ -32,11 +32,22 @@
{{^minItems}}
{{#maxItems}}
@Size(max={{maxItems}})
{{/maxItems}}
{{/minItems}}
{{/maxItems}}
{{/minItems}}
{{! check for integer / number=decimal type}}
{{#isInteger}}
{{#minimum}}
// @Min({{minimum}})
@Min({{minimum}})
{{/minimum}}
{{#maximum}}
// @Max({{maximum}})
{{/maximum}}
@Max({{maximum}})
{{/maximum}}
{{/isInteger}}
{{^isInteger}}
{{#minimum}}
@DecimalMin("{{minimum}}")
{{/minimum}}
{{#maximum}}
@DecimalMax("{{maximum}}")
{{/maximum}}
{{/isInteger}}

View File

@@ -78,8 +78,8 @@ public class FormatTest {
* @return integer
**/
@ApiModelProperty(value = "")
// @Min(10)
// @Max(100)
@Min(10)
@Max(100)
public Integer getInteger() {
return integer;
}
@@ -100,8 +100,8 @@ public class FormatTest {
* @return int32
**/
@ApiModelProperty(value = "")
// @Min(20)
// @Max(200)
@Min(20)
@Max(200)
public Integer getInt32() {
return int32;
}
@@ -141,8 +141,8 @@ public class FormatTest {
**/
@ApiModelProperty(required = true, value = "")
@NotNull
// @Min(32.1)
// @Max(543.2)
@DecimalMin("32.1")
@DecimalMax("543.2")
public BigDecimal getNumber() {
return number;
}
@@ -163,8 +163,8 @@ public class FormatTest {
* @return _float
**/
@ApiModelProperty(value = "")
// @Min(54.3)
// @Max(987.6)
@DecimalMin("54.3")
@DecimalMax("987.6")
public Float getFloat() {
return _float;
}
@@ -185,8 +185,8 @@ public class FormatTest {
* @return _double
**/
@ApiModelProperty(value = "")
// @Min(67.8)
// @Max(123.4)
@DecimalMin("67.8")
@DecimalMax("123.4")
public Double getDouble() {
return _double;
}

View File

@@ -78,8 +78,8 @@ public class FormatTest {
* @return integer
**/
@ApiModelProperty(value = "")
// @Min(10)
// @Max(100)
@Min(10)
@Max(100)
public Integer getInteger() {
return integer;
}
@@ -100,8 +100,8 @@ public class FormatTest {
* @return int32
**/
@ApiModelProperty(value = "")
// @Min(20)
// @Max(200)
@Min(20)
@Max(200)
public Integer getInt32() {
return int32;
}
@@ -141,8 +141,8 @@ public class FormatTest {
**/
@ApiModelProperty(required = true, value = "")
@NotNull
// @Min(32.1)
// @Max(543.2)
@DecimalMin("32.1")
@DecimalMax("543.2")
public BigDecimal getNumber() {
return number;
}
@@ -163,8 +163,8 @@ public class FormatTest {
* @return _float
**/
@ApiModelProperty(value = "")
// @Min(54.3)
// @Max(987.6)
@DecimalMin("54.3")
@DecimalMax("987.6")
public Float getFloat() {
return _float;
}
@@ -185,8 +185,8 @@ public class FormatTest {
* @return _double
**/
@ApiModelProperty(value = "")
// @Min(67.8)
// @Max(123.4)
@DecimalMin("67.8")
@DecimalMax("123.4")
public Double getDouble() {
return _double;
}