Feature: Enable validation (#5391)

When useBeanValidation is enabled make sure the annotation @Valid
is added to the attributes of the model.
This commit is contained in:
Kenny Jones
2017-04-24 11:18:04 -04:00
committed by wing328
parent aa85468932
commit c14da15b3e
66 changed files with 480 additions and 21 deletions

View File

@@ -1,4 +1,5 @@
{{#required}}
@NotNull
{{/required}}
{{>beanValidationCore}}
{{>beanValidationCore}}
@Valid

View File

@@ -5,16 +5,16 @@ 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
@Size: minItems && maxItems set
}}{{#minItems}}{{#maxItems}} @Size(min={{minItems}},max={{maxItems}}){{/maxItems}}{{/minItems}}{{!
@Size: minItems set, maxItems not
@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}}{{!
@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 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 @@
{{#required}} @NotNull{{/required}}{{>beanValidationCore}}
{{#required}} @NotNull{{/required}}{{>beanValidationCore}}

View File

@@ -7,8 +7,10 @@ import java.util.Objects;
import java.io.Serializable;
{{/serializableModel}}
{{#useBeanValidation}}
import javax.validation.Valid;
import javax.validation.constraints.*;
{{/useBeanValidation}}
{{#models}}
{{#model}}
{{#isEnum}}