@aeriajs/validation 0.0.138 → 0.0.139
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/validate.d.ts +12 -3
- package/dist/validate.js +9 -1
- package/dist/validate.mjs +7 -0
- package/package.json +1 -1
package/dist/validate.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ export type ValidateOptions = {
|
|
|
5
5
|
tolerateExtraneous?: boolean;
|
|
6
6
|
throwOnError?: boolean;
|
|
7
7
|
coerce?: boolean;
|
|
8
|
-
parentProperty?:
|
|
8
|
+
parentProperty?: Property | Description;
|
|
9
9
|
};
|
|
10
10
|
export declare const makeValidationError: <TValidationError extends ValidationError>(error: TValidationError) => TValidationError;
|
|
11
11
|
export declare const validateProperty: <TWhat>(what: TWhat, property: Property | undefined, options?: ValidateOptions) => Result.Either<PropertyValidationError | ValidationError, unknown>;
|
|
@@ -18,7 +18,7 @@ export declare const validateWholeness: (what: Record<string, unknown>, schema:
|
|
|
18
18
|
};
|
|
19
19
|
};
|
|
20
20
|
} | undefined;
|
|
21
|
-
export declare const validate: <TWhat, const TJsonSchema extends
|
|
21
|
+
export declare const validate: <TWhat, const TJsonSchema extends Property | Description>(what: TWhat | undefined, schema: TJsonSchema, options?: ValidateOptions) => {
|
|
22
22
|
readonly _tag: "Error";
|
|
23
23
|
readonly error: PropertyValidationError | ValidationError;
|
|
24
24
|
readonly result: undefined;
|
|
@@ -27,7 +27,16 @@ export declare const validate: <TWhat, const TJsonSchema extends Omit<Descriptio
|
|
|
27
27
|
readonly error: undefined;
|
|
28
28
|
readonly result: InferSchema<TJsonSchema, {}>;
|
|
29
29
|
};
|
|
30
|
-
export declare const
|
|
30
|
+
export declare const validateWithRefs: <TWhat, const TJsonSchema extends Property | Description>(what: TWhat | undefined, schema: TJsonSchema, options?: ValidateOptions, descriptions?: Record<string, Description>) => Promise<{
|
|
31
|
+
readonly _tag: "Error";
|
|
32
|
+
readonly error: PropertyValidationError | ValidationError;
|
|
33
|
+
readonly result: undefined;
|
|
34
|
+
} | {
|
|
35
|
+
readonly _tag: "Result";
|
|
36
|
+
readonly error: undefined;
|
|
37
|
+
readonly result: InferSchema<TJsonSchema, {}>;
|
|
38
|
+
}>;
|
|
39
|
+
export declare const validator: <const TJsonSchema extends Property | Description>(schema: TJsonSchema, options?: ValidateOptions) => readonly [InferSchema<TJsonSchema>, <TWhat>(what: TWhat) => {
|
|
31
40
|
readonly _tag: "Error";
|
|
32
41
|
readonly error: PropertyValidationError | ValidationError;
|
|
33
42
|
readonly result: undefined;
|
package/dist/validate.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.validator = exports.validate = exports.validateWholeness = exports.validateRefs = exports.validateProperty = exports.makeValidationError = void 0;
|
|
3
|
+
exports.validator = exports.validateWithRefs = exports.validate = exports.validateWholeness = exports.validateRefs = exports.validateProperty = exports.makeValidationError = void 0;
|
|
4
4
|
const types_1 = require("@aeriajs/types");
|
|
5
5
|
const common_1 = require("@aeriajs/common");
|
|
6
6
|
const types_2 = require("@aeriajs/types");
|
|
@@ -307,6 +307,14 @@ const validate = (what, schema, options = {}) => {
|
|
|
307
307
|
return types_1.Result.result(resultCopy);
|
|
308
308
|
};
|
|
309
309
|
exports.validate = validate;
|
|
310
|
+
const validateWithRefs = async (what, schema, options = {}, descriptions) => {
|
|
311
|
+
const { error: refsError } = await (0, exports.validateRefs)(what, schema, options, descriptions);
|
|
312
|
+
if (refsError) {
|
|
313
|
+
return types_1.Result.error(refsError);
|
|
314
|
+
}
|
|
315
|
+
return (0, exports.validate)(what, schema, options);
|
|
316
|
+
};
|
|
317
|
+
exports.validateWithRefs = validateWithRefs;
|
|
310
318
|
const validator = (schema, options = {}) => {
|
|
311
319
|
return [
|
|
312
320
|
{},
|
package/dist/validate.mjs
CHANGED
|
@@ -287,6 +287,13 @@ export const validate = (what, schema, options = {}) => {
|
|
|
287
287
|
}
|
|
288
288
|
return Result.result(resultCopy);
|
|
289
289
|
};
|
|
290
|
+
export const validateWithRefs = async (what, schema, options = {}, descriptions) => {
|
|
291
|
+
const { error: refsError } = await validateRefs(what, schema, options, descriptions);
|
|
292
|
+
if (refsError) {
|
|
293
|
+
return Result.error(refsError);
|
|
294
|
+
}
|
|
295
|
+
return validate(what, schema, options);
|
|
296
|
+
};
|
|
290
297
|
export const validator = (schema, options = {}) => {
|
|
291
298
|
return [
|
|
292
299
|
{},
|