@naturalcycles/nodejs-lib 15.97.2 → 15.97.3
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.
|
|
@@ -168,13 +180,6 @@ export declare class JSchema<OUT, Opt> implements StandardSchemaV1<unknown, OUT>
|
|
|
168
180
|
}
|
|
169
181
|
export declare class JBuilder<OUT, Opt> extends JSchema<OUT, Opt> {
|
|
170
182
|
protected setErrorMessage(ruleName: string, errorMessage: string | undefined): void;
|
|
171
|
-
/**
|
|
172
|
-
* A helper function that takes a type parameter and compares it with the type inferred from the schema.
|
|
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`.
|
|
176
|
-
*/
|
|
177
|
-
isOfType<ExpectedType>(): ExactMatch<ExpectedType, OUT> extends true ? this : never;
|
|
178
183
|
$schema($schema: string): this;
|
|
179
184
|
$schemaDraft7(): this;
|
|
180
185
|
$id($id: string): this;
|
|
@@ -197,11 +202,6 @@ export declare class JBuilder<OUT, Opt> extends JSchema<OUT, Opt> {
|
|
|
197
202
|
*/
|
|
198
203
|
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
204
|
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
205
|
/**
|
|
206
206
|
* Locks the given schema chain and no other modification can be done to it.
|
|
207
207
|
*/
|
|
@@ -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.
|
|
@@ -369,15 +385,6 @@ export class JBuilder extends JSchema {
|
|
|
369
385
|
this.schema.errorMessages ||= {};
|
|
370
386
|
this.schema.errorMessages[ruleName] = errorMessage;
|
|
371
387
|
}
|
|
372
|
-
/**
|
|
373
|
-
* A helper function that takes a type parameter and compares it with the type inferred from the schema.
|
|
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`.
|
|
377
|
-
*/
|
|
378
|
-
isOfType() {
|
|
379
|
-
return this.cloneAndUpdateSchema({ hasIsOfTypeCheck: true });
|
|
380
|
-
}
|
|
381
388
|
$schema($schema) {
|
|
382
389
|
return this.cloneAndUpdateSchema({ $schema });
|
|
383
390
|
}
|
|
@@ -463,13 +470,6 @@ export class JBuilder extends JSchema {
|
|
|
463
470
|
anyOf: [this.build(), { type: 'null' }],
|
|
464
471
|
});
|
|
465
472
|
}
|
|
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
473
|
/**
|
|
474
474
|
* Locks the given schema chain and no other modification can be done to it.
|
|
475
475
|
*/
|
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.
|
|
@@ -521,16 +539,6 @@ export class JBuilder<OUT, Opt> extends JSchema<OUT, Opt> {
|
|
|
521
539
|
this.schema.errorMessages[ruleName] = errorMessage
|
|
522
540
|
}
|
|
523
541
|
|
|
524
|
-
/**
|
|
525
|
-
* A helper function that takes a type parameter and compares it with the type inferred from the schema.
|
|
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`.
|
|
529
|
-
*/
|
|
530
|
-
isOfType<ExpectedType>(): ExactMatch<ExpectedType, OUT> extends true ? this : never {
|
|
531
|
-
return this.cloneAndUpdateSchema({ hasIsOfTypeCheck: true }) as any
|
|
532
|
-
}
|
|
533
|
-
|
|
534
542
|
$schema($schema: string): this {
|
|
535
543
|
return this.cloneAndUpdateSchema({ $schema })
|
|
536
544
|
}
|
|
@@ -637,14 +645,6 @@ export class JBuilder<OUT, Opt> extends JSchema<OUT, Opt> {
|
|
|
637
645
|
})
|
|
638
646
|
}
|
|
639
647
|
|
|
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
648
|
/**
|
|
649
649
|
* Locks the given schema chain and no other modification can be done to it.
|
|
650
650
|
*/
|