Test case
1 generated file · +33 −0test/inputs/regressions/unicode-codepoint-length.schema
Aschema-dartdefault / TopLevel.dart+33 −0
| @@ -0,0 +1,33 @@ | ||
| 1 | +// To parse this JSON data, do | |
| 2 | +// | |
| 3 | +// final topLevel = topLevelFromJson(jsonString); | |
| 4 | + | |
| 5 | +import 'dart:convert'; | |
| 6 | + | |
| 7 | +TopLevel topLevelFromJson(String str) => TopLevel.fromJson(json.decode(str)); | |
| 8 | + | |
| 9 | +String topLevelToJson(TopLevel data) => json.encode(data.toJson()); | |
| 10 | + | |
| 11 | +class TopLevel { | |
| 12 | + final String exact; | |
| 13 | + final String maximum; | |
| 14 | + final String minimum; | |
| 15 | + | |
| 16 | + TopLevel({ | |
| 17 | + required this.exact, | |
| 18 | + required this.maximum, | |
| 19 | + required this.minimum, | |
| 20 | + }); | |
| 21 | + | |
| 22 | + factory TopLevel.fromJson(Map<String, dynamic> json) => TopLevel( | |
| 23 | + exact: ((x) => RegExp("^[^!]+\u0024").hasMatch(x) ? x : throw FormatException("Expected matching string"))(((x) => x.runes.length >= 2 && x.runes.length <= 2 ? x : throw FormatException("Expected bounded string"))(json["exact"])), | |
| 24 | + maximum: ((x) => true && x.runes.length <= 1 ? x : throw FormatException("Expected bounded string"))(json["maximum"]), | |
| 25 | + minimum: ((x) => x.runes.length >= 2 && true ? x : throw FormatException("Expected bounded string"))(json["minimum"]), | |
| 26 | + ); | |
| 27 | + | |
| 28 | + Map<String, dynamic> toJson() => { | |
| 29 | + "exact": exact, | |
| 30 | + "maximum": maximum, | |
| 31 | + "minimum": minimum, | |
| 32 | + }; | |
| 33 | +} |
Test case
1 generated file · +6 −6test/inputs/schema/minmaxlength.schema
Mschema-dartdefault / TopLevel.dart+6 −6
| @@ -30,14 +30,14 @@ class TopLevel { | ||
| 30 | 30 | }); |
| 31 | 31 | |
| 32 | 32 | factory TopLevel.fromJson(Map<String, dynamic> json) => TopLevel( |
| 33 | - intersection: ((x) => x.length >= 4 && x.length <= 5 ? x : throw FormatException("Expected bounded string"))(json["intersection"]), | |
| 33 | + intersection: ((x) => x.runes.length >= 4 && x.runes.length <= 5 ? x : throw FormatException("Expected bounded string"))(json["intersection"]), | |
| 34 | 34 | inUnion: json["inUnion"], |
| 35 | - maxlength: ((x) => true && x.length <= 5 ? x : throw FormatException("Expected bounded string"))(json["maxlength"]), | |
| 36 | - minlength: ((x) => x.length >= 3 && true ? x : throw FormatException("Expected bounded string"))(json["minlength"]), | |
| 37 | - minMaxIntersection: ((x) => x.length >= 3 && x.length <= 5 ? x : throw FormatException("Expected bounded string"))(json["minMaxIntersection"]), | |
| 38 | - minmaxlength: ((x) => x.length >= 3 && x.length <= 5 ? x : throw FormatException("Expected bounded string"))(json["minmaxlength"]), | |
| 35 | + maxlength: ((x) => true && x.runes.length <= 5 ? x : throw FormatException("Expected bounded string"))(json["maxlength"]), | |
| 36 | + minlength: ((x) => x.runes.length >= 3 && true ? x : throw FormatException("Expected bounded string"))(json["minlength"]), | |
| 37 | + minMaxIntersection: ((x) => x.runes.length >= 3 && x.runes.length <= 5 ? x : throw FormatException("Expected bounded string"))(json["minMaxIntersection"]), | |
| 38 | + minmaxlength: ((x) => x.runes.length >= 3 && x.runes.length <= 5 ? x : throw FormatException("Expected bounded string"))(json["minmaxlength"]), | |
| 39 | 39 | minMaxUnion: json["minMaxUnion"], |
| 40 | - union: ((x) => x.length >= 3 && x.length <= 6 ? x : throw FormatException("Expected bounded string"))(json["union"]), | |
| 40 | + union: ((x) => x.runes.length >= 3 && x.runes.length <= 6 ? x : throw FormatException("Expected bounded string"))(json["union"]), | |
| 41 | 41 | ); |
| 42 | 42 | |
| 43 | 43 | Map<String, dynamic> toJson() => { |
Test case
1 generated file · +2 −2test/inputs/schema/optional-const-ref.schema
Mschema-dartdefault / TopLevel.dart+2 −2
| @@ -30,10 +30,10 @@ class TopLevel { | ||
| 30 | 30 | factory TopLevel.fromJson(Map<String, dynamic> json) => TopLevel( |
| 31 | 31 | coordinates: json["coordinates"] == null ? null : List<Coordinate>.from(json["coordinates"]!.map((x) => Coordinate.fromJson(x))), |
| 32 | 32 | count: json["count"] == null ? null : ((x) => x >= 1 && x <= 100 ? x : throw FormatException("Expected bounded number"))(json["count"]), |
| 33 | - label: json["label"] == null ? null : ((x) => x.length >= 2 && x.length <= 16 ? x : throw FormatException("Expected bounded string"))(json["label"]), | |
| 33 | + label: json["label"] == null ? null : ((x) => x.runes.length >= 2 && x.runes.length <= 16 ? x : throw FormatException("Expected bounded string"))(json["label"]), | |
| 34 | 34 | requiredCoordinates: List<Coordinate>.from(json["requiredCoordinates"].map((x) => Coordinate.fromJson(x))), |
| 35 | 35 | requiredCount: ((x) => x >= 1 && x <= 100 ? x : throw FormatException("Expected bounded number"))(json["requiredCount"]), |
| 36 | - requiredLabel: ((x) => x.length >= 2 && x.length <= 16 ? x : throw FormatException("Expected bounded string"))(json["requiredLabel"]), | |
| 36 | + requiredLabel: ((x) => x.runes.length >= 2 && x.runes.length <= 16 ? x : throw FormatException("Expected bounded string"))(json["requiredLabel"]), | |
| 37 | 37 | weight: json["weight"]?.toDouble() == null ? null : ((x) => x >= 0.5 && x <= 99.5 ? x : throw FormatException("Expected bounded number"))(json["weight"]?.toDouble()), |
| 38 | 38 | ); |
Test case
1 generated file · +1 −1test/inputs/schema/optional-constraints.schema
Mschema-dartdefault / TopLevel.dart+1 −1
| @@ -27,7 +27,7 @@ class TopLevel { | ||
| 27 | 27 | optDouble: json["optDouble"]?.toDouble() == null ? null : ((x) => x >= 0.5 && x <= 99.5 ? x : throw FormatException("Expected bounded number"))(json["optDouble"]?.toDouble()), |
| 28 | 28 | optInt: json["optInt"] == null ? null : ((x) => x >= 0 && x <= 100 ? x : throw FormatException("Expected bounded number"))(json["optInt"]), |
| 29 | 29 | optPattern: json["optPattern"] == null ? null : ((x) => RegExp("^[a-z]+\u0024").hasMatch(x) ? x : throw FormatException("Expected matching string"))(json["optPattern"]), |
| 30 | - optString: json["optString"] == null ? null : ((x) => x.length >= 3 && x.length <= 10 ? x : throw FormatException("Expected bounded string"))(json["optString"]), | |
| 30 | + optString: json["optString"] == null ? null : ((x) => x.runes.length >= 3 && x.runes.length <= 10 ? x : throw FormatException("Expected bounded string"))(json["optString"]), | |
| 31 | 31 | reqZeroMin: ((x) => x >= 0 && x <= 100 ? x : throw FormatException("Expected bounded number"))(json["reqZeroMin"]), |
| 32 | 32 | ); |
Test case
1 generated file · +2 −2test/inputs/schema/renaming-bug.schema
Mschema-dartdefault / TopLevel.dart+2 −2
| @@ -69,7 +69,7 @@ class Berry { | ||
| 69 | 69 | |
| 70 | 70 | factory Berry.fromJson(Map<String, dynamic> json) => Berry( |
| 71 | 71 | color: json["color"] == null ? null : Color.fromJson(json["color"]), |
| 72 | - name: json["name"] == null ? null : ((x) => x.length >= 1 && true ? x : throw FormatException("Expected bounded string"))(json["name"]), | |
| 72 | + name: json["name"] == null ? null : ((x) => x.runes.length >= 1 && true ? x : throw FormatException("Expected bounded string"))(json["name"]), | |
| 73 | 73 | shapes: json["shapes"] == null ? null : List<Shape>.from(json["shapes"]!.map((x) => Shape.fromJson(x))), |
| 74 | 74 | ); |
| 75 | 75 | |
| @@ -227,7 +227,7 @@ class Vehicle { | ||
| 227 | 227 | |
| 228 | 228 | factory Vehicle.fromJson(Map<String, dynamic> json) => Vehicle( |
| 229 | 229 | brand: json["brand"], |
| 230 | - id: json["id"] == null ? null : ((x) => x.length >= 1 && true ? x : throw FormatException("Expected bounded string"))(json["id"]), | |
| 230 | + id: json["id"] == null ? null : ((x) => x.runes.length >= 1 && true ? x : throw FormatException("Expected bounded string"))(json["id"]), | |
| 231 | 231 | speed: json["speed"] == null ? null : Speed.fromJson(json["speed"]), |
| 232 | 232 | subModule: json["subModule"], |
| 233 | 233 | type: json["type"] == null ? null : VehicleType.fromJson(json["type"]), |
Test case
1 generated file · +1 −1test/inputs/schema/schema-constraints.schema
Mschema-dartdefault / TopLevel.dart+1 −1
| @@ -18,7 +18,7 @@ class TopLevel { | ||
| 18 | 18 | }); |
| 19 | 19 | |
| 20 | 20 | factory TopLevel.fromJson(Map<String, dynamic> json) => TopLevel( |
| 21 | - minMaxLength: ((x) => x.length >= 5 && x.length <= 5 ? x : throw FormatException("Expected bounded string"))(json["minMaxLength"]), | |
| 21 | + minMaxLength: ((x) => x.runes.length >= 5 && x.runes.length <= 5 ? x : throw FormatException("Expected bounded string"))(json["minMaxLength"]), | |
| 22 | 22 | percent: ((x) => x >= 0 && x <= 1 ? x : throw FormatException("Expected bounded number"))(json["percent"]?.toDouble()), |
| 23 | 23 | ); |
No generated files match these filters.