@naturalcycles/nodejs-lib 15.97.2 → 15.97.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.
|
@@ -136,6 +136,18 @@ export declare class JSchema<OUT, Opt> implements StandardSchemaV1<unknown, OUT>
|
|
|
136
136
|
private _getBuiltSchema;
|
|
137
137
|
private _getCompiled;
|
|
138
138
|
getSchema(): JsonSchema;
|
|
139
|
+
/**
|
|
140
|
+
* @deprecated
|
|
141
|
+
* The usage of this function is discouraged as it defeats the purpose of having type-safe validation.
|
|
142
|
+
*/
|
|
143
|
+
castAs<T>(): JSchema<T, Opt>;
|
|
144
|
+
/**
|
|
145
|
+
* A helper function that takes a type parameter and compares it with the type inferred from the schema.
|
|
146
|
+
*
|
|
147
|
+
* When the type inferred from the schema differs from the passed-in type,
|
|
148
|
+
* the schema becomes unusable, by turning its type into `never`.
|
|
149
|
+
*/
|
|
150
|
+
isOfType<ExpectedType>(): ExactMatch<ExpectedType, OUT> extends true ? this : never;
|
|
139
151
|
/**
|
|
140
152
|
* Produces a "clean schema object" without methods.
|
|
141
153
|
* Same as if it would be JSON.stringified.
|
|
@@ -169,12 +181,10 @@ export declare class JSchema<OUT, Opt> implements StandardSchemaV1<unknown, OUT>
|
|
|
169
181
|
export declare class JBuilder<OUT, Opt> extends JSchema<OUT, Opt> {
|
|
170
182
|
protected setErrorMessage(ruleName: string, errorMessage: string | undefined): void;
|
|
171
183
|
/**
|
|
172
|
-
*
|
|
173
|
-
*
|
|
174
|
-
* When the type inferred from the schema differs from the passed-in type,
|
|
175
|
-
* the schema becomes unusable, by turning its type into `never`.
|
|
184
|
+
* @deprecated
|
|
185
|
+
* The usage of this function is discouraged as it defeats the purpose of having type-safe validation.
|
|
176
186
|
*/
|
|
177
|
-
|
|
187
|
+
castAs<T>(): JBuilder<T, Opt>;
|
|
178
188
|
$schema($schema: string): this;
|
|
179
189
|
$schemaDraft7(): this;
|
|
180
190
|
$id($id: string): this;
|
|
@@ -197,11 +207,6 @@ export declare class JBuilder<OUT, Opt> extends JSchema<OUT, Opt> {
|
|
|
197
207
|
*/
|
|
198
208
|
optional<T extends readonly (string | number | boolean | null)[] | undefined = undefined>(optionalValues?: T): T extends readonly (string | number | boolean | null)[] ? JSchema<OUT | undefined, true> : JBuilder<OUT | undefined, true>;
|
|
199
209
|
nullable(): JBuilder<OUT | null, Opt>;
|
|
200
|
-
/**
|
|
201
|
-
* @deprecated
|
|
202
|
-
* The usage of this function is discouraged as it defeats the purpose of having type-safe validation.
|
|
203
|
-
*/
|
|
204
|
-
castAs<T>(): JBuilder<T, Opt>;
|
|
205
210
|
/**
|
|
206
211
|
* Locks the given schema chain and no other modification can be done to it.
|
|
207
212
|
*/
|
|
@@ -274,6 +274,22 @@ export class JSchema {
|
|
|
274
274
|
getSchema() {
|
|
275
275
|
return this.schema;
|
|
276
276
|
}
|
|
277
|
+
/**
|
|
278
|
+
* @deprecated
|
|
279
|
+
* The usage of this function is discouraged as it defeats the purpose of having type-safe validation.
|
|
280
|
+
*/
|
|
281
|
+
castAs() {
|
|
282
|
+
return this;
|
|
283
|
+
}
|
|
284
|
+
/**
|
|
285
|
+
* A helper function that takes a type parameter and compares it with the type inferred from the schema.
|
|
286
|
+
*
|
|
287
|
+
* When the type inferred from the schema differs from the passed-in type,
|
|
288
|
+
* the schema becomes unusable, by turning its type into `never`.
|
|
289
|
+
*/
|
|
290
|
+
isOfType() {
|
|
291
|
+
return this.cloneAndUpdateSchema({ hasIsOfTypeCheck: true });
|
|
292
|
+
}
|
|
277
293
|
/**
|
|
278
294
|
* Produces a "clean schema object" without methods.
|
|
279
295
|
* Same as if it would be JSON.stringified.
|
|
@@ -370,13 +386,11 @@ export class JBuilder extends JSchema {
|
|
|
370
386
|
this.schema.errorMessages[ruleName] = errorMessage;
|
|
371
387
|
}
|
|
372
388
|
/**
|
|
373
|
-
*
|
|
374
|
-
*
|
|
375
|
-
* When the type inferred from the schema differs from the passed-in type,
|
|
376
|
-
* the schema becomes unusable, by turning its type into `never`.
|
|
389
|
+
* @deprecated
|
|
390
|
+
* The usage of this function is discouraged as it defeats the purpose of having type-safe validation.
|
|
377
391
|
*/
|
|
378
|
-
|
|
379
|
-
return this
|
|
392
|
+
castAs() {
|
|
393
|
+
return this;
|
|
380
394
|
}
|
|
381
395
|
$schema($schema) {
|
|
382
396
|
return this.cloneAndUpdateSchema({ $schema });
|
|
@@ -463,13 +477,6 @@ export class JBuilder extends JSchema {
|
|
|
463
477
|
anyOf: [this.build(), { type: 'null' }],
|
|
464
478
|
});
|
|
465
479
|
}
|
|
466
|
-
/**
|
|
467
|
-
* @deprecated
|
|
468
|
-
* The usage of this function is discouraged as it defeats the purpose of having type-safe validation.
|
|
469
|
-
*/
|
|
470
|
-
castAs() {
|
|
471
|
-
return this;
|
|
472
|
-
}
|
|
473
480
|
/**
|
|
474
481
|
* Locks the given schema chain and no other modification can be done to it.
|
|
475
482
|
*/
|
package/package.json
CHANGED
|
@@ -396,6 +396,24 @@ export class JSchema<OUT, Opt>
|
|
|
396
396
|
return this.schema
|
|
397
397
|
}
|
|
398
398
|
|
|
399
|
+
/**
|
|
400
|
+
* @deprecated
|
|
401
|
+
* The usage of this function is discouraged as it defeats the purpose of having type-safe validation.
|
|
402
|
+
*/
|
|
403
|
+
castAs<T>(): JSchema<T, Opt> {
|
|
404
|
+
return this as unknown as JSchema<T, Opt>
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
/**
|
|
408
|
+
* A helper function that takes a type parameter and compares it with the type inferred from the schema.
|
|
409
|
+
*
|
|
410
|
+
* When the type inferred from the schema differs from the passed-in type,
|
|
411
|
+
* the schema becomes unusable, by turning its type into `never`.
|
|
412
|
+
*/
|
|
413
|
+
isOfType<ExpectedType>(): ExactMatch<ExpectedType, OUT> extends true ? this : never {
|
|
414
|
+
return this.cloneAndUpdateSchema({ hasIsOfTypeCheck: true }) as any
|
|
415
|
+
}
|
|
416
|
+
|
|
399
417
|
/**
|
|
400
418
|
* Produces a "clean schema object" without methods.
|
|
401
419
|
* Same as if it would be JSON.stringified.
|
|
@@ -522,13 +540,11 @@ export class JBuilder<OUT, Opt> extends JSchema<OUT, Opt> {
|
|
|
522
540
|
}
|
|
523
541
|
|
|
524
542
|
/**
|
|
525
|
-
*
|
|
526
|
-
*
|
|
527
|
-
* When the type inferred from the schema differs from the passed-in type,
|
|
528
|
-
* the schema becomes unusable, by turning its type into `never`.
|
|
543
|
+
* @deprecated
|
|
544
|
+
* The usage of this function is discouraged as it defeats the purpose of having type-safe validation.
|
|
529
545
|
*/
|
|
530
|
-
|
|
531
|
-
return this
|
|
546
|
+
override castAs<T>(): JBuilder<T, Opt> {
|
|
547
|
+
return this as unknown as JBuilder<T, Opt>
|
|
532
548
|
}
|
|
533
549
|
|
|
534
550
|
$schema($schema: string): this {
|
|
@@ -637,14 +653,6 @@ export class JBuilder<OUT, Opt> extends JSchema<OUT, Opt> {
|
|
|
637
653
|
})
|
|
638
654
|
}
|
|
639
655
|
|
|
640
|
-
/**
|
|
641
|
-
* @deprecated
|
|
642
|
-
* The usage of this function is discouraged as it defeats the purpose of having type-safe validation.
|
|
643
|
-
*/
|
|
644
|
-
castAs<T>(): JBuilder<T, Opt> {
|
|
645
|
-
return this as unknown as JBuilder<T, Opt>
|
|
646
|
-
}
|
|
647
|
-
|
|
648
656
|
/**
|
|
649
657
|
* Locks the given schema chain and no other modification can be done to it.
|
|
650
658
|
*/
|