All Downloads are FREE. Search and download functionalities are using the official Maven repository.

templates.kotlin-micronaut.common.params.validation.mustache Maven / Gradle / Ivy


{{#isNullable}}
    @Nullable
{{/isNullable}}
{{^isNullable}}
    {{#required}}
        {{#isReadOnly}}
    @Nullable
        {{/isReadOnly}}
    {{/required}}
    {{^required}}
    @Nullable
    {{/required}}
{{/isNullable}}
{{!All the validation}}
{{#useBeanValidation}}
    {{^isNullable}}
        {{#required}}
            {{^isReadOnly}}
    @NotNull{{#vendorExtensions.x-not-null-message}}(message = "{{{.}}}"){{/vendorExtensions.x-not-null-message}}
            {{/isReadOnly}}
        {{/required}}
    {{/isNullable}}
    {{!Validate all pojos and enums}}
    {{^isUuid}}
    {{^isContainer}}
        {{#isModel}}
    @Valid
        {{/isModel}}
    {{/isContainer}}
    {{!Pattern}}
    {{#pattern}}
        {{^isEmail}}{{^isByteArray}}{{^isDate}}{{^isDateTime}}
    @Pattern(regexp = "{{{pattern}}}"{{#vendorExtensions.x-pattern-message}}, message = "{{{.}}}"{{/vendorExtensions.x-pattern-message}})
        {{/isDateTime}}{{/isDate}}{{/isByteArray}}{{/isEmail}}
    {{/pattern}}
    {{!Min length && max length}}
    {{#minLength}}
        {{#maxLength}}
    @Size(min = {{minLength}}, max = {{maxLength}}{{#vendorExtensions.x-size-message}}, message = "{{{.}}}"{{/vendorExtensions.x-size-message}})
        {{/maxLength}}
    {{/minLength}}
    {{#minLength}}{{^maxLength}}
    @Size(min = {{minLength}}{{#vendorExtensions.x-size-message}}, message = "{{{.}}}"{{/vendorExtensions.x-size-message}})
    {{/maxLength}}{{/minLength}}
    {{^minLength}}{{#maxLength}}
    @Size(max = {{maxLength}}{{#vendorExtensions.x-size-message}}, message = "{{{.}}}"{{/vendorExtensions.x-size-message}})
    {{/maxLength}}{{/minLength}}
    {{!Size}}
    {{#minItems}}{{#maxItems}}
    @Size(min = {{minItems}}, max = {{maxItems}}{{#vendorExtensions.x-size-message}}, message = "{{{.}}}"{{/vendorExtensions.x-size-message}})
    {{/maxItems}}{{/minItems}}
    {{#minItems}}{{^maxItems}}
    @Size(min = {{minItems}}{{#vendorExtensions.x-size-message}}, message = "{{{.}}}"{{/vendorExtensions.x-size-message}})
    {{/maxItems}}{{/minItems}}
    {{^minItems}}{{#maxItems}}
    @Size(max = {{maxItems}}{{#vendorExtensions.x-size-message}}, message = "{{{.}}}"{{/vendorExtensions.x-size-message}})
    {{/maxItems}}{{/minItems}}
    {{!Email}}
    {{#isEmail}}
    @Email{{#pattern}}(regexp = "{{{pattern}}}"{{#vendorExtensions.x-pattern-message}}, message = "{{{.}}}"{{/vendorExtensions.x-pattern-message}}){{/pattern}}{{^pattern}}{{#vendorExtensions.x-pattern-message}}(message = "{{{.}}}"){{/vendorExtensions.x-pattern-message}}{{/pattern}}
    {{/isEmail}}
    {{!check for integer or long / all others=decimal type with @Decimal isInteger set}}
    {{#isInteger}}
        {{#minimum}}
    @Min({{#vendorExtensions.x-minimum-message}}value = {{/vendorExtensions.x-minimum-message}}{{{.}}}{{#vendorExtensions.x-minimum-message}}, message = "{{{.}}}"{{/vendorExtensions.x-minimum-message}})
        {{/minimum}}
        {{#maximum}}
    @Max({{#vendorExtensions.x-maximum-message}}value = {{/vendorExtensions.x-maximum-message}}{{{.}}}{{#vendorExtensions.x-maximum-message}}, message = "{{{.}}}"{{/vendorExtensions.x-maximum-message}})
        {{/maximum}}
    {{/isInteger}}
    {{!isLong set}}
    {{#isLong}}
        {{#minimum}}
    @Min({{#vendorExtensions.x-minimum-message}}value = {{/vendorExtensions.x-minimum-message}}{{{.}}}L{{#vendorExtensions.x-minimum-message}}, message = "{{{.}}}"{{/vendorExtensions.x-minimum-message}})
        {{/minimum}}
        {{#maximum}}
    @Max({{#vendorExtensions.x-maximum-message}}value = {{/vendorExtensions.x-maximum-message}}{{{.}}}L{{#vendorExtensions.x-maximum-message}}, message = "{{{.}}}"{{/vendorExtensions.x-maximum-message}})
        {{/maximum}}
    {{/isLong}}
    {{!Not Integer, not Long => we have a decimal value!}}
    {{^isInteger}}
        {{^isLong}}{{!minimum for decimal value}}
            {{#minimum}}
    @DecimalMin({{#exclusiveMinimum}}value = {{/exclusiveMinimum}}{{^exclusiveMinimum}}{{#vendorExtensions.x-minimum-message}}value = {{/vendorExtensions.x-minimum-message}}{{/exclusiveMinimum}}"{{minimum}}"{{#exclusiveMinimum}}, inclusive = false{{/exclusiveMinimum}}{{#vendorExtensions.x-minimum-message}}, message = "{{{.}}}"{{/vendorExtensions.x-minimum-message}})
            {{/minimum}}
    {{!maximal for decimal value}}
            {{#maximum}}
    @DecimalMax({{#exclusiveMaximum}}value = {{/exclusiveMaximum}}{{^exclusiveMaximum}}{{#vendorExtensions.x-maximum-message}}value = {{/vendorExtensions.x-maximum-message}}{{/exclusiveMaximum}}"{{maximum}}"{{#exclusiveMaximum}}, inclusive = false{{/exclusiveMaximum}}{{#vendorExtensions.x-maximum-message}}, message = "{{{.}}}"{{/vendorExtensions.x-maximum-message}})
            {{/maximum}}
        {{/isLong}}
    {{/isInteger}}
    {{/isUuid}}
{{/useBeanValidation}}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy