@fgv/ts-json-base 5.0.0-17 → 5.0.0-19

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.
@@ -30,7 +30,7 @@ const json_1 = require("../json");
30
30
  * @public
31
31
  */
32
32
  exports.jsonPrimitive = new ts_utils_1.Validation.Base.GenericValidator({
33
- validator: (from, ctx) => {
33
+ validator: (from, ctx, self) => {
34
34
  if (from === null) {
35
35
  return true;
36
36
  }
@@ -58,7 +58,7 @@ exports.jsonPrimitive = new ts_utils_1.Validation.Base.GenericValidator({
58
58
  * @public
59
59
  */
60
60
  exports.jsonObject = new ts_utils_1.Validation.Base.GenericValidator({
61
- validator: (from, ctx) => {
61
+ validator: (from, ctx, self) => {
62
62
  if (!(0, json_1.isJsonObject)(from)) {
63
63
  return (0, ts_utils_1.fail)('not a valid JSON object.');
64
64
  }
@@ -83,7 +83,7 @@ exports.jsonObject = new ts_utils_1.Validation.Base.GenericValidator({
83
83
  * @public
84
84
  */
85
85
  exports.jsonArray = new ts_utils_1.Validation.Base.GenericValidator({
86
- validator: (from, ctx) => {
86
+ validator: (from, ctx, self) => {
87
87
  if (!(0, json_1.isJsonArray)(from)) {
88
88
  return (0, ts_utils_1.fail)('not an array');
89
89
  }
@@ -109,7 +109,7 @@ exports.jsonArray = new ts_utils_1.Validation.Base.GenericValidator({
109
109
  * @public
110
110
  */
111
111
  exports.jsonValue = new ts_utils_1.Validation.Base.GenericValidator({
112
- validator: (from, ctx) => {
112
+ validator: (from, ctx, self) => {
113
113
  if ((0, json_1.isJsonArray)(from)) {
114
114
  const result = exports.jsonArray.validate(from, ctx);
115
115
  return result.success === true ? true : result;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fgv/ts-json-base",
3
- "version": "5.0.0-17",
3
+ "version": "5.0.0-19",
4
4
  "description": "Typescript types and basic functions for working with json",
5
5
  "main": "lib/index.js",
6
6
  "types": "dist/ts-json-base.d.ts",
@@ -39,12 +39,12 @@
39
39
  "@rushstack/eslint-patch": "~1.12.0",
40
40
  "@rushstack/eslint-config": "~4.4.0",
41
41
  "eslint-plugin-tsdoc": "~0.4.0",
42
- "@fgv/ts-utils-jest": "5.0.0-17",
43
- "@fgv/ts-utils": "5.0.0-17",
44
- "@fgv/ts-extras": "5.0.0-17"
42
+ "@fgv/ts-utils": "5.0.0-19",
43
+ "@fgv/ts-extras": "5.0.0-19",
44
+ "@fgv/ts-utils-jest": "5.0.0-19"
45
45
  },
46
46
  "peerDependencies": {
47
- "@fgv/ts-utils": "5.0.0-17"
47
+ "@fgv/ts-utils": "5.0.0-19"
48
48
  },
49
49
  "scripts": {
50
50
  "build": "heft test --clean",
@@ -40,7 +40,11 @@ export interface IJsonValidatorContext {
40
40
  */
41
41
  export const jsonPrimitive: Validator<JsonPrimitive, IJsonValidatorContext> =
42
42
  new Validation.Base.GenericValidator({
43
- validator: (from: unknown, ctx?: IJsonValidatorContext): boolean | Failure<JsonPrimitive> => {
43
+ validator: (
44
+ from: unknown,
45
+ ctx?: IJsonValidatorContext,
46
+ self?: Validator<JsonPrimitive, IJsonValidatorContext>
47
+ ): boolean | Failure<JsonPrimitive> => {
44
48
  if (from === null) {
45
49
  return true;
46
50
  }
@@ -69,7 +73,11 @@ export const jsonPrimitive: Validator<JsonPrimitive, IJsonValidatorContext> =
69
73
  * @public
70
74
  */
71
75
  export const jsonObject: Validator<JsonObject, IJsonValidatorContext> = new Validation.Base.GenericValidator({
72
- validator: (from: unknown, ctx?: IJsonValidatorContext) => {
76
+ validator: (
77
+ from: unknown,
78
+ ctx?: IJsonValidatorContext,
79
+ self?: Validator<JsonObject, IJsonValidatorContext>
80
+ ) => {
73
81
  if (!isJsonObject(from)) {
74
82
  return fail('not a valid JSON object.');
75
83
  }
@@ -95,7 +103,11 @@ export const jsonObject: Validator<JsonObject, IJsonValidatorContext> = new Vali
95
103
  * @public
96
104
  */
97
105
  export const jsonArray: Validator<JsonArray, IJsonValidatorContext> = new Validation.Base.GenericValidator({
98
- validator: (from: unknown, ctx?: IJsonValidatorContext) => {
106
+ validator: (
107
+ from: unknown,
108
+ ctx?: IJsonValidatorContext,
109
+ self?: Validator<JsonArray, IJsonValidatorContext>
110
+ ) => {
99
111
  if (!isJsonArray(from)) {
100
112
  return fail('not an array');
101
113
  }
@@ -125,7 +137,11 @@ export const jsonValue: Validator<JsonValue, IJsonValidatorContext> = new Valida
125
137
  JsonValue,
126
138
  IJsonValidatorContext
127
139
  >({
128
- validator: (from: unknown, ctx?: IJsonValidatorContext) => {
140
+ validator: (
141
+ from: unknown,
142
+ ctx?: IJsonValidatorContext,
143
+ self?: Validator<JsonValue, IJsonValidatorContext>
144
+ ) => {
129
145
  if (isJsonArray(from)) {
130
146
  const result = jsonArray.validate(from, ctx);
131
147
  return result.success === true ? true : result;