quicktype-core 23.3.2 → 23.3.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/Messages.js CHANGED
@@ -92,6 +92,9 @@ function messageError(kind, properties) {
92
92
  else if (typeof value !== "string") {
93
93
  valueString = JSON.stringify(value);
94
94
  }
95
+ else {
96
+ valueString = value;
97
+ }
95
98
  userMessage = userMessage.replace("${" + name + "}", valueString);
96
99
  }
97
100
  throw new QuickTypeError(message, kind, userMessage, properties);
@@ -767,33 +767,43 @@ class CPlusPlusRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
767
767
  return;
768
768
  const { minMax, minMaxLength, pattern } = constraints;
769
769
  // TODO is there a better way to check if property.type is an integer or a number?
770
+ // We only generate this to classify the underlying type, so we
771
+ // always pass `false` for `isOptional` — otherwise `cppType`
772
+ // wraps the type in the optional<> container and the comparisons
773
+ // below never match.
770
774
  const cppType = this.cppType(property.type, {
771
775
  needsForwardIndirection: true,
772
776
  needsOptionalIndirection: true,
773
777
  inJsonNamespace: false,
774
- }, true, false, property.isOptional);
778
+ }, true, false, false);
779
+ // Compare bounds against `undefined` explicitly, since 0 is a
780
+ // valid constraint value too.
775
781
  res.set(jsonName, [
776
782
  this.constraintMember(jsonName),
777
783
  "(",
778
- (minMax === null || minMax === void 0 ? void 0 : minMax[0]) && cppType === "int64_t"
784
+ (minMax === null || minMax === void 0 ? void 0 : minMax[0]) !== undefined && cppType === "int64_t"
779
785
  ? String(minMax[0])
780
786
  : this._nulloptType,
781
787
  ", ",
782
- (minMax === null || minMax === void 0 ? void 0 : minMax[1]) && cppType === "int64_t"
788
+ (minMax === null || minMax === void 0 ? void 0 : minMax[1]) !== undefined && cppType === "int64_t"
783
789
  ? String(minMax[1])
784
790
  : this._nulloptType,
785
791
  ", ",
786
- (minMax === null || minMax === void 0 ? void 0 : minMax[0]) && cppType === "double"
792
+ (minMax === null || minMax === void 0 ? void 0 : minMax[0]) !== undefined && cppType === "double"
787
793
  ? String(minMax[0])
788
794
  : this._nulloptType,
789
795
  ", ",
790
- (minMax === null || minMax === void 0 ? void 0 : minMax[1]) && cppType === "double"
796
+ (minMax === null || minMax === void 0 ? void 0 : minMax[1]) !== undefined && cppType === "double"
791
797
  ? String(minMax[1])
792
798
  : this._nulloptType,
793
799
  ", ",
794
- (minMaxLength === null || minMaxLength === void 0 ? void 0 : minMaxLength[0]) ? String(minMaxLength[0]) : this._nulloptType,
800
+ (minMaxLength === null || minMaxLength === void 0 ? void 0 : minMaxLength[0]) !== undefined
801
+ ? String(minMaxLength[0])
802
+ : this._nulloptType,
795
803
  ", ",
796
- (minMaxLength === null || minMaxLength === void 0 ? void 0 : minMaxLength[1]) ? String(minMaxLength[1]) : this._nulloptType,
804
+ (minMaxLength === null || minMaxLength === void 0 ? void 0 : minMaxLength[1]) !== undefined
805
+ ? String(minMaxLength[1])
806
+ : this._nulloptType,
797
807
  ", ",
798
808
  pattern === undefined
799
809
  ? this._nulloptType
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "quicktype-core",
3
- "version": "23.3.2",
3
+ "version": "23.3.4",
4
4
  "description": "The quicktype engine as a library",
5
5
  "license": "Apache-2.0",
6
6
  "main": "dist/index.js",