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

templates.kotlin.validations_2.mustache Maven / Gradle / Ivy

There is a newer version: 0.113
Show newest version
{{#type}}{{#DATE_TIME}}{{&indent}}        require({{#negate}}!{{/negate}}JSONValidation.isDateTime({{&kotlinName}})) { "{{&displayName}} {{^negate}}does not match{{/negate}}{{#negate}}matches{{/negate}} format date-time - ${{&kotlinName}}" }
{{/DATE_TIME}}{{#DATE}}{{&indent}}        require({{#negate}}!{{/negate}}JSONValidation.isDate({{&kotlinName}})) { "{{&displayName}} {{^negate}}does not match{{/negate}}{{#negate}}matches{{/negate}} format date - ${{&kotlinName}}" }
{{/DATE}}{{#TIME}}{{&indent}}        require({{#negate}}!{{/negate}}JSONValidation.isTime({{&kotlinName}})) { "{{&displayName}} {{^negate}}does not match{{/negate}}{{#negate}}matches{{/negate}} format time - ${{&kotlinName}}" }
{{/TIME}}{{#UUID}}{{&indent}}        require({{#negate}}!{{/negate}}JSONValidation.isUUID({{&kotlinName}})) { "{{&displayName}} {{^negate}}does not match{{/negate}}{{#negate}}matches{{/negate}} format uuid - ${{&kotlinName}}" }
{{/UUID}}{{#URI}}{{&indent}}        require({{#negate}}!{{/negate}}JSONValidation.isURI({{&kotlinName}})) { "{{&displayName}} {{^negate}}does not match{{/negate}}{{#negate}}matches{{/negate}} format uri - ${{&kotlinName}}" }
{{/URI}}{{#URI_REFERENCE}}{{&indent}}        require({{#negate}}!{{/negate}}JSONValidation.isURIReference({{&kotlinName}})) { "{{&displayName}} {{^negate}}does not match{{/negate}}{{#negate}}matches{{/negate}} format uri-reference - ${{&kotlinName}}" }
{{/URI_REFERENCE}}{{#EMAIL}}{{&indent}}        require({{#negate}}!{{/negate}}JSONValidation.isEmail({{&kotlinName}})) { "{{&displayName}} {{^negate}}does not match{{/negate}}{{#negate}}matches{{/negate}} format email - ${{&kotlinName}}" }
{{/EMAIL}}{{#URI_TEMPLATE}}{{&indent}}        require({{#negate}}!{{/negate}}JSONValidation.isURITemplate({{&kotlinName}})) { "{{&displayName}} {{^negate}}does not match{{/negate}}{{#negate}}matches{{/negate}} format uri-template - ${{&kotlinName}}" }
{{/URI_TEMPLATE}}{{#HOSTNAME}}{{&indent}}        require({{#negate}}!{{/negate}}JSONValidation.isHostname({{&kotlinName}})) { "{{&displayName}} {{^negate}}does not match{{/negate}}{{#negate}}matches{{/negate}} format hostname - ${{&kotlinName}}" }
{{/HOSTNAME}}{{#IPV4}}{{&indent}}        require({{#negate}}!{{/negate}}JSONValidation.isIPV4({{&kotlinName}})) { "{{&displayName}} {{^negate}}does not match{{/negate}}{{#negate}}matches{{/negate}} format ipv4 - ${{&kotlinName}}" }
{{/IPV4}}{{#IPV6}}{{&indent}}        require({{#negate}}!{{/negate}}JSONValidation.isIPV6({{&kotlinName}})) { "{{&displayName}} {{^negate}}does not match{{/negate}}{{#negate}}matches{{/negate}} format ipv6 - ${{&kotlinName}}" }
{{/IPV6}}{{#DURATION}}{{&indent}}        require({{#negate}}!{{/negate}}JSONValidation.isDuration({{&kotlinName}})) { "{{&displayName}} {{^negate}}does not match{{/negate}}{{#negate}}matches{{/negate}} format duration - ${{&kotlinName}}" }
{{/DURATION}}{{#JSON_POINTER}}{{&indent}}        require({{#negate}}!{{/negate}}JSONValidation.isJSONPointer({{&kotlinName}})) { "{{&displayName}} {{^negate}}does not match{{/negate}}{{#negate}}matches{{/negate}} format json-pointer - ${{&kotlinName}}" }
{{/JSON_POINTER}}{{#RELATIVE_JSON_POINTER}}{{&indent}}        require({{#negate}}!{{/negate}}JSONValidation.isRelativeJSONPointer({{&kotlinName}})) { "{{&displayName}} {{^negate}}does not match{{/negate}}{{#negate}}matches{{/negate}} format relative-json-pointer - ${{&kotlinName}}" }
{{/RELATIVE_JSON_POINTER}}{{#PATTERN}}{{&indent}}        require({{#negate}}!{{/negate}}{{&value.staticName}}.containsMatchIn({{&kotlinName}})) { "{{&displayName}} {{^negate}}does not match{{/negate}}{{#negate}}matches{{/negate}} pattern ${{&value.staticName}} - ${{&kotlinName}}" }
{{/PATTERN}}{{#MAXIMUM_INT}}{{&indent}}        require({{&kotlinName}} {{>cond_le}} {{&value}}) { "{{&displayName}} {{#negate}}not {{/negate}}> maximum {{&value}} - ${{&kotlinName}}" }
{{/MAXIMUM_INT}}{{#MAXIMUM_LONG}}{{&indent}}        require({{&kotlinName}} {{>cond_le}} {{&value}}L) { "{{&displayName}} {{#negate}}not {{/negate}}> maximum {{&value}} - ${{&kotlinName}}" }
{{/MAXIMUM_LONG}}{{#MINIMUM_INT}}{{&indent}}        require({{&kotlinName}} {{>cond_ge}} {{&value}}) { "{{&displayName}} {{#negate}}not {{/negate}}< minimum {{&value}} - ${{&kotlinName}}" }
{{/MINIMUM_INT}}{{#MINIMUM_LONG}}{{&indent}}        require({{&kotlinName}} {{^negate}}>= {{/negate}}{{#negate}}< {{/negate}}{{&value}}L) { "{{&displayName}} {{#negate}}not {{/negate}}< minimum {{&value}} - ${{&kotlinName}}" }
{{/MINIMUM_LONG}}{{#MAXIMUM_DECIMAL}}{{&indent}}        require({{&kotlinName}} {{>cond_le}} {{&value.staticName}}) { "{{&displayName}} {{#negate}}not {{/negate}}> maximum {{&value.value}} - ${{&kotlinName}}" }
{{/MAXIMUM_DECIMAL}}{{#MAXIMUM_DECIMAL_ZERO}}{{&indent}}        require({{&kotlinName}} {{>cond_le}} {{&decimalClass.className}}.ZERO) { "{{&displayName}} {{#negate}}not {{/negate}}> maximum 0 - ${{&kotlinName}}" }
{{/MAXIMUM_DECIMAL_ZERO}}{{#EXCLUSIVE_MAXIMUM_DECIMAL}}{{&indent}}        require({{&kotlinName}} {{>cond_lt}} {{&value.staticName}}) { "{{&displayName}} {{#negate}}not {{/negate}}>= exclusive maximum {{&value.value}} - ${{&kotlinName}}" }
{{/EXCLUSIVE_MAXIMUM_DECIMAL}}{{#EXCLUSIVE_MAXIMUM_DECIMAL_ZERO}}{{&indent}}        require({{&kotlinName}} {{>cond_lt}} {{&decimalClass.className}}.ZERO) { "{{&displayName}} {{#negate}}not {{/negate}}>= exclusive maximum 0 - ${{&kotlinName}}" }
{{/EXCLUSIVE_MAXIMUM_DECIMAL_ZERO}}{{#MINIMUM_DECIMAL}}{{&indent}}        require({{&kotlinName}} {{>cond_ge}} {{&value.staticName}}) { "{{&displayName}} {{#negate}}not {{/negate}}< minimum {{&value.value}} - ${{&kotlinName}}" }
{{/MINIMUM_DECIMAL}}{{#MINIMUM_DECIMAL_ZERO}}{{&indent}}        require({{&kotlinName}} {{>cond_ge}} {{&decimalClass.className}}.ZERO) { "{{&displayName}} {{#negate}}not {{/negate}}< minimum 0 - ${{&kotlinName}}" }
{{/MINIMUM_DECIMAL_ZERO}}{{#EXCLUSIVE_MINIMUM_DECIMAL}}{{&indent}}        require({{&kotlinName}} {{>cond_gt}} {{&value.staticName}}) { "{{&displayName}} {{#negate}}not {{/negate}}<= exclusive minimum {{&value.value}} - ${{&kotlinName}}" }
{{/EXCLUSIVE_MINIMUM_DECIMAL}}{{#EXCLUSIVE_MINIMUM_DECIMAL_ZERO}}{{&indent}}        require({{&kotlinName}} {{>cond_gt}} {{&decimalClass.className}}.ZERO) { "{{&displayName}} {{#negate}}not {{/negate}}<= exclusive minimum 0 - ${{&kotlinName}}" }
{{/EXCLUSIVE_MINIMUM_DECIMAL_ZERO}}{{#RANGE_DECIMAL}}{{&indent}}        require({{&kotlinName}} {{#negate}}!{{/negate}}in {{&value.first.staticName}}..{{&value.second.staticName}}) { "{{&displayName}} {{^negate}}not {{/negate}}in range {{#value}}{{&first.value}}..{{&second.value}}{{/value}} - ${{&kotlinName}}" }
{{/RANGE_DECIMAL}}{{#RANGE_INT}}{{&indent}}        require({{&kotlinName}} {{#negate}}!{{/negate}}in {{#value}}{{&first}}..{{&second}}{{/value}}) { "{{&displayName}} {{^negate}}not {{/negate}}in range {{#value}}{{&first}}..{{&second}}{{/value}} - ${{&kotlinName}}" }
{{/RANGE_INT}}{{#RANGE_LONG}}{{&indent}}        require({{&kotlinName}} {{#negate}}!{{/negate}}in {{#value}}{{&first}}L..{{&second}}L{{/value}}) { "{{&displayName}} {{^negate}}not {{/negate}}in range {{#value}}{{&first}}..{{&second}}{{/value}} - ${{&kotlinName}}" }
{{/RANGE_LONG}}{{#MULTIPLE_INT}}{{&indent}}        require({{&kotlinName}}.rem({{&value}}) {{>cond_eq}} 0) { "{{&displayName}} {{^negate}}not {{/negate}}a multiple of {{&value}} - ${{&kotlinName}}" }
{{/MULTIPLE_INT}}{{#MULTIPLE_LONG}}{{&indent}}        require({{&kotlinName}}.rem({{&value}}L) {{>cond_eq}} 0L) { "{{&displayName}} {{^negate}}not {{/negate}}a multiple of {{&value}} - ${{&kotlinName}}" }
{{/MULTIPLE_LONG}}{{#MULTIPLE_DECIMAL}}{{&indent}}        require({{&kotlinName}}.rem({{&value.staticName}}).compareTo({{&decimalClass.className}}.ZERO) {{>cond_eq}} 0) { "{{&displayName}} {{^negate}}not {{/negate}}a multiple of {{&value.value}} - ${{&kotlinName}}" }
{{/MULTIPLE_DECIMAL}}{{#MAX_ITEMS}}{{&indent}}        require({{&kotlinName}}.size {{>cond_le}} {{&value}}) { "{{&displayName}} length {{#negate}}not {{/negate}}> maximum {{&value}} - ${{&openBrace}}{{&kotlinName}}.size}" }
{{/MAX_ITEMS}}{{#MIN_ITEMS}}{{&indent}}        require({{&kotlinName}}.{{#value}}{{#isOne}}is{{^negate}}Not{{/negate}}Empty(){{/isOne}}{{^isOne}}size {{>cond_ge}} {{&rawNumber}}{{/isOne}}{{/value}}) { "{{&displayName}} length {{#negate}}not {{/negate}}< minimum {{&value}} - ${{&openBrace}}{{&kotlinName}}.size}" }
{{/MIN_ITEMS}}{{#CONST_ITEMS}}{{&indent}}        require({{&kotlinName}}.size {{>cond_eq}} {{&value}}) { "{{&displayName}} length {{^negate}}not{{/negate}}{{#negate}}is{{/negate}} constant value {{&value}} - ${{&openBrace}}{{&kotlinName}}.size}" }
{{/CONST_ITEMS}}{{#RANGE_ITEMS}}{{&indent}}        require({{&kotlinName}}.size {{#negate}}!{{/negate}}in {{#value}}{{&first}}..{{&second}}{{/value}}) { "{{&displayName}} length {{^negate}}not {{/negate}}in range {{#value}}{{&first}}..{{&second}}{{/value}} - ${{&openBrace}}{{&kotlinName}}.size}" }
{{/RANGE_ITEMS}}{{#MAX_LENGTH}}{{&indent}}        require({{&kotlinName}}.length {{>cond_le}} {{&value}}) { "{{&displayName}} length {{#negate}}not {{/negate}}> maximum {{&value}} - ${{&openBrace}}{{&kotlinName}}.length}" }
{{/MAX_LENGTH}}{{#MIN_LENGTH}}{{&indent}}        require({{&kotlinName}}.{{#value}}{{#isOne}}is{{^negate}}Not{{/negate}}Empty(){{/isOne}}{{^isOne}}length {{>cond_ge}} {{&rawNumber}}{{/isOne}}{{/value}}) { "{{&displayName}} length {{#negate}}not {{/negate}}< minimum {{&value}} - ${{&openBrace}}{{&kotlinName}}.length}" }
{{/MIN_LENGTH}}{{#CONST_LENGTH}}{{&indent}}        require({{&kotlinName}}.{{#value}}length {{>cond_eq}} {{&rawNumber}}{{/value}}) { "{{&displayName}} length {{^negate}}!={{/negate}}{{#negate}}=={{/negate}} constant {{&value}} - ${{&openBrace}}{{&kotlinName}}.length}" }
{{/CONST_LENGTH}}{{#RANGE_LENGTH}}{{&indent}}        require({{&kotlinName}}.{{#value}}length {{#negate}}!{{/negate}}in {{&first}}..{{&second}}{{/value}}) { "{{&displayName}} length {{^negate}}not {{/negate}}in range {{#value}}{{&first}}..{{&second}}{{/value}} - ${{&openBrace}}{{&kotlinName}}.length}" }
{{/RANGE_LENGTH}}{{#CONST_STRING}}{{&indent}}        require({{&kotlinName}} {{>cond_eq}} {{&value.staticName}}) { "{{&displayName}} {{^negate}}not{{/negate}}{{#negate}}is{{/negate}} constant value ${{&value.staticName}} - ${{&kotlinName}}" }
{{/CONST_STRING}}{{#CONST_INT}}{{&indent}}        require({{&kotlinName}} {{>cond_eq}} {{&value}}) { "{{&displayName}} {{^negate}}not{{/negate}}{{#negate}}is{{/negate}} constant value {{&value}} - ${{&kotlinName}}" }
{{/CONST_INT}}{{#CONST_LONG}}{{&indent}}        require({{&kotlinName}} == {{&value}}L) { "{{&displayName}} not constant value {{&value}} - ${{&kotlinName}}" }
{{/CONST_LONG}}{{#CONST_DECIMAL}}{{&indent}}        require({{&kotlinName}}.compareTo({{&value.staticName}}) {{>cond_eq}} 0) { "{{&displayName}} {{^negate}}not{{/negate}}{{#negate}}is{{/negate}} constant value {{&value.value}} - ${{&kotlinName}}" }
{{/CONST_DECIMAL}}{{#CONST_DECIMAL_ZERO}}{{&indent}}        require({{&kotlinName}}.compareTo({{&decimalClass.className}}.ZERO) {{>cond_eq}} 0) { "{{&displayName}} {{^negate}}not{{/negate}}{{#negate}}is{{/negate}} constant value 0 - ${{&kotlinName}}" }
{{/CONST_DECIMAL_ZERO}}{{#CONST_ENUM}}{{&indent}}        require({{&kotlinName}} {{>cond_eq}} {{&value.kotlinString}}) { "{{&displayName}} {{^negate}}not{{/negate}}{{#negate}}is{{/negate}} constant value {{&value.value}} - ${{&kotlinName}}" }
{{/CONST_ENUM}}{{#ENUM_STRING}}{{&indent}}        require({{&kotlinName}} {{#negate}}!{{/negate}}in {{&value.staticName}}) { "{{&displayName}} {{^negate}}not {{/negate}}in enumerated values - ${{&kotlinName}}" }
{{/ENUM_STRING}}{{#ENUM_INT}}{{&indent}}        require({{&kotlinName}} {{#negate}}!{{/negate}}in {{&value.staticName}}) { "{{&displayName}} {{^negate}}not {{/negate}}in enumerated values - ${{&kotlinName}}" }
{{/ENUM_INT}}{{#ARRAY_ITEMS}}{{&indent}}        for ({{&arrayItems.kotlinName}} in {{&kotlinName}}){{#arrayItems}}{{#indent.increment}}{{#validations}}{{!
}}{{#first}}{{^last}} {{&openBrace}}{{/last}}
{{#nullable}}{{&indent}}        if ({{&kotlinName}} != null){{^last}} {{&openBrace}}{{/last}}
{{#indent.increment}}{{>validations_2}}{{/indent.increment}}{{/nullable}}{{!
}}{{^nullable}}{{>validations_2}}{{/nullable}}{{/first}}{{!
}}{{^first}}{{#nullable}}{{#indent.increment}}{{>validations_2}}{{/indent.increment}}{{/nullable}}{{^nullable}}{{>validations_2}}{{/nullable}}{{!
}}{{#last}}{{#nullable}}{{&indent}}        }
{{/nullable}}{{&indent}}    }
{{/last}}{{/first}}{{/validations}}{{/indent.increment}}{{/arrayItems}}{{/ARRAY_ITEMS}}{{#PATTERN_PROPERTIES}}{{&indent}}        cg_map.entries.forEach { (key, value) ->
{{&indent}}            if ({{#value}}{{&third.staticName}}.containsMatchIn(key)){{#second}}{{#validations}}{{#first}} {{&openBrace}}{{/first}}{{/validations}}{{/second}}
{{&indent}}                require({{#second}}{{>additional_props_type_check}}{{/second}}) { "$key is not the correct type, expecting {{#second}}{{>type}}{{/second}}" }
{{#second}}{{#validations}}{{#indent.increment}}{{#indent.increment}}{{#mapEntryContext}}{{>validations_2}}{{/mapEntryContext}}{{/indent.increment}}{{/indent.increment}}{{#last}}            }
{{/last}}{{/validations}}{{/second}}{{/value}}        }
{{/PATTERN_PROPERTIES}}{{#ADDITIONAL_PROPERTIES}}{{&indent}}        cg_map.entries.forEach { (key, value) ->
{{#properties}}{{#first}}{{&indent}}            if ({{/first}}{{^first}} && {{/first}}key != "{{&kotlinName}}"{{#last}}{{#patternProperties}} && !{{&third.staticName}}.containsMatchIn(key){{/patternProperties}}){{#value}}{{#validations}}{{#first}} {{&openBrace}}{{/first}}{{/validations}}{{/value}}
    {{/last}}{{/properties}}{{^properties}}{{#patternProperties}}{{#first}}{{&indent}}            if ({{/first}}{{^first}} && {{/first}}!{{&third.staticName}}.containsMatchIn(key){{/patternProperties}})){{#value}}{{#validations}}{{#first}} {{&openBrace}}{{/first}}{{/validations}}{{/value}}
{{/properties}}{{&indent}}            require({{#value}}{{>additional_props_type_check}}{{/value}}) { "$key is not the correct type, expecting {{#value}}{{>type}}{{/value}}" }
{{#value}}{{#validations}}{{#indent.increment}}{{#indent.increment}}{{#mapEntryContext}}{{>validations_2}}{{/mapEntryContext}}{{/indent.increment}}{{/indent.increment}}{{#last}}            }
{{/last}}{{/validations}}{{/value}}{{&indent}}        }
{{/ADDITIONAL_PROPERTIES}}{{#UNEXPECTED_PROPERTIES}}{{&indent}}        cg_map.keys.forEach { key ->
{{#hasProperties}}{{&indent}}            if ({{#properties}}{{^first}} && {{/first}}key != "{{&kotlinName}}"{{/properties}}{{#patternProperties}} && !{{&third.staticName}}.containsMatchIn(key){{/patternProperties}})
    {{/hasProperties}}{{^hasProperties}}{{#hasPatternProperties}}{{&indent}}            if ({{#patternProperties}}{{^first}} && {{/first}}!{{&third.staticName}}.containsMatchIn(key){{/patternProperties}})
    {{/hasPatternProperties}}{{/hasProperties}}{{&indent}}            throw IllegalArgumentException("Unexpected field $key")
{{&indent}}        }
{{/UNEXPECTED_PROPERTIES}}{{#MINIMUM_PROPERTIES}}{{#value}}{{#isOne}}{{&indent}}        require(cg_map.isNotEmpty()) { "Number of properties < minimum 1" }
{{/isOne}}{{^isOne}}{{&indent}}        require(cg_map.size >= {{&rawNumber}}) { "Number of properties < minimum {{&rawNumber}} - ${cg_map.size}" }
{{/isOne}}{{/value}}{{/MINIMUM_PROPERTIES}}{{#MAXIMUM_PROPERTIES}}{{&indent}}        require(cg_map.size <= {{&value}}) { "Number of properties > maximum {{&value}} - ${cg_map.size}" }
{{/MAXIMUM_PROPERTIES}}{{#CONST_PROPERTIES}}{{&indent}}        require(cg_map.size == {{&value}}) { "Number of properties != constant {{&value}} - ${cg_map.size}" }
{{/CONST_PROPERTIES}}{{#RANGE_PROPERTIES}}{{&indent}}        require(cg_map.size in {{&value.first}}..{{&value.second}}) { "Number of properties not in range {{&value.first}}..{{&value.second}} - ${cg_map.size}" }
{{/RANGE_PROPERTIES}}{{/type}}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy