Test case
1 generated file · +42 −0test/inputs/schema/integer-type.schema
Mschema-kotlindefault / TopLevel.kt+42 −0
| @@ -35,6 +35,48 @@ data class TopLevel ( | ||
| 35 | 35 | |
| 36 | 36 | val unbounded: Long |
| 37 | 37 | ) { |
| 38 | + init { | |
| 39 | + require(aboveI32Max >= 0) | |
| 40 | + } | |
| 41 | + init { | |
| 42 | + require(aboveI32Max <= 2147483648) | |
| 43 | + } | |
| 44 | + init { | |
| 45 | + require(belowI32Min >= -2147483649) | |
| 46 | + } | |
| 47 | + init { | |
| 48 | + require(belowI32Min <= 0) | |
| 49 | + } | |
| 50 | + init { | |
| 51 | + require(i32Range >= -2147483648) | |
| 52 | + } | |
| 53 | + init { | |
| 54 | + require(i32Range <= 2147483647) | |
| 55 | + } | |
| 56 | + init { | |
| 57 | + require(largeBounds >= -9007199254740991) | |
| 58 | + } | |
| 59 | + init { | |
| 60 | + require(largeBounds <= 9007199254740991) | |
| 61 | + } | |
| 62 | + init { | |
| 63 | + require(onlyMaximum <= 0) | |
| 64 | + } | |
| 65 | + init { | |
| 66 | + require(onlyMinimum >= 0) | |
| 67 | + } | |
| 68 | + init { | |
| 69 | + require(smallNegative >= -100) | |
| 70 | + } | |
| 71 | + init { | |
| 72 | + require(smallNegative <= 0) | |
| 73 | + } | |
| 74 | + init { | |
| 75 | + require(smallPositive >= 0) | |
| 76 | + } | |
| 77 | + init { | |
| 78 | + require(smallPositive <= 100) | |
| 79 | + } | |
| 38 | 80 | public fun toJson() = klaxon.toJsonString(this) |
| 39 | 81 | |
| 40 | 82 | companion object { |
Test case
1 generated file · +30 −0test/inputs/schema/minmax-integer.schema
Mschema-kotlindefault / TopLevel.kt+30 −0
| @@ -18,6 +18,36 @@ data class TopLevel ( | ||
| 18 | 18 | val minMaxUnion: Long, |
| 19 | 19 | val union: Long |
| 20 | 20 | ) { |
| 21 | + init { | |
| 22 | + require(intersection >= 4) | |
| 23 | + } | |
| 24 | + init { | |
| 25 | + require(intersection <= 5) | |
| 26 | + } | |
| 27 | + init { | |
| 28 | + require(max <= 5) | |
| 29 | + } | |
| 30 | + init { | |
| 31 | + require(min >= 3) | |
| 32 | + } | |
| 33 | + init { | |
| 34 | + require(minmax >= 3) | |
| 35 | + } | |
| 36 | + init { | |
| 37 | + require(minmax <= 5) | |
| 38 | + } | |
| 39 | + init { | |
| 40 | + require(minMaxIntersection >= 3) | |
| 41 | + } | |
| 42 | + init { | |
| 43 | + require(minMaxIntersection <= 5) | |
| 44 | + } | |
| 45 | + init { | |
| 46 | + require(union >= 3) | |
| 47 | + } | |
| 48 | + init { | |
| 49 | + require(union <= 6) | |
| 50 | + } | |
| 21 | 51 | public fun toJson() = klaxon.toJsonString(this) |
| 22 | 52 | |
| 23 | 53 | companion object { |
Test case
1 generated file · +30 −0test/inputs/schema/minmax.schema
Mschema-kotlindefault / TopLevel.kt+30 −0
| @@ -18,6 +18,36 @@ data class TopLevel ( | ||
| 18 | 18 | val minMaxUnion: Double, |
| 19 | 19 | val union: Double |
| 20 | 20 | ) { |
| 21 | + init { | |
| 22 | + require(intersection >= 4) | |
| 23 | + } | |
| 24 | + init { | |
| 25 | + require(intersection <= 5) | |
| 26 | + } | |
| 27 | + init { | |
| 28 | + require(max <= 5) | |
| 29 | + } | |
| 30 | + init { | |
| 31 | + require(min >= 3) | |
| 32 | + } | |
| 33 | + init { | |
| 34 | + require(minmax >= 3) | |
| 35 | + } | |
| 36 | + init { | |
| 37 | + require(minmax <= 5) | |
| 38 | + } | |
| 39 | + init { | |
| 40 | + require(minMaxIntersection >= 3) | |
| 41 | + } | |
| 42 | + init { | |
| 43 | + require(minMaxIntersection <= 5) | |
| 44 | + } | |
| 45 | + init { | |
| 46 | + require(union >= 3) | |
| 47 | + } | |
| 48 | + init { | |
| 49 | + require(union <= 6) | |
| 50 | + } | |
| 21 | 51 | public fun toJson() = klaxon.toJsonString(this) |
| 22 | 52 | |
| 23 | 53 | companion object { |
Test case
1 generated file · +18 −0test/inputs/schema/optional-const-ref.schema
Mschema-kotlindefault / TopLevel.kt+18 −0
| @@ -17,6 +17,24 @@ data class TopLevel ( | ||
| 17 | 17 | val requiredLabel: String, |
| 18 | 18 | val weight: Double? = null |
| 19 | 19 | ) { |
| 20 | + init { | |
| 21 | + count?.let { require(it >= 1) } | |
| 22 | + } | |
| 23 | + init { | |
| 24 | + count?.let { require(it <= 100) } | |
| 25 | + } | |
| 26 | + init { | |
| 27 | + require(requiredCount >= 1) | |
| 28 | + } | |
| 29 | + init { | |
| 30 | + require(requiredCount <= 100) | |
| 31 | + } | |
| 32 | + init { | |
| 33 | + weight?.let { require(it >= 0.5) } | |
| 34 | + } | |
| 35 | + init { | |
| 36 | + weight?.let { require(it <= 99.5) } | |
| 37 | + } | |
| 20 | 38 | public fun toJson() = klaxon.toJsonString(this) |
| 21 | 39 | |
| 22 | 40 | companion object { |
Test case
1 generated file · +18 −0test/inputs/schema/optional-constraints.schema
Mschema-kotlindefault / TopLevel.kt+18 −0
| @@ -15,6 +15,24 @@ data class TopLevel ( | ||
| 15 | 15 | val optString: String? = null, |
| 16 | 16 | val reqZeroMin: Long |
| 17 | 17 | ) { |
| 18 | + init { | |
| 19 | + optDouble?.let { require(it >= 0.5) } | |
| 20 | + } | |
| 21 | + init { | |
| 22 | + optDouble?.let { require(it <= 99.5) } | |
| 23 | + } | |
| 24 | + init { | |
| 25 | + optInt?.let { require(it >= 0) } | |
| 26 | + } | |
| 27 | + init { | |
| 28 | + optInt?.let { require(it <= 100) } | |
| 29 | + } | |
| 30 | + init { | |
| 31 | + require(reqZeroMin >= 0) | |
| 32 | + } | |
| 33 | + init { | |
| 34 | + require(reqZeroMin <= 100) | |
| 35 | + } | |
| 18 | 36 | public fun toJson() = klaxon.toJsonString(this) |
| 19 | 37 | |
| 20 | 38 | companion object { |
Test case
1 generated file · +6 −0test/inputs/schema/schema-constraints.schema
Mschema-kotlindefault / TopLevel.kt+6 −0
| @@ -12,6 +12,12 @@ data class TopLevel ( | ||
| 12 | 12 | val minMaxLength: String, |
| 13 | 13 | val percent: Double |
| 14 | 14 | ) { |
| 15 | + init { | |
| 16 | + require(percent >= 0) | |
| 17 | + } | |
| 18 | + init { | |
| 19 | + require(percent <= 1) | |
| 20 | + } | |
| 15 | 21 | public fun toJson() = klaxon.toJsonString(this) |
| 16 | 22 | |
| 17 | 23 | companion object { |
No generated files match these filters.