knight-validation 4.0.0 → 4.0.1
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/lib/lib/Validator.d.ts +7 -3
- package/lib/lib/Validator.js +9 -2
- package/package.json +1 -1
package/lib/lib/Validator.d.ts
CHANGED
|
@@ -10,8 +10,13 @@ export interface ValidatorEntry<T = any> {
|
|
|
10
10
|
validator?: Validator;
|
|
11
11
|
condition?: (object: T) => Promise<boolean>;
|
|
12
12
|
}
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
export interface ValidatorFactory<T = any> {
|
|
14
|
+
create(): Validator<T>;
|
|
15
|
+
}
|
|
16
|
+
export declare class SimpleValidatorFactory<T = any> implements ValidatorFactory<T> {
|
|
17
|
+
createFn: () => Validator<T>;
|
|
18
|
+
constructor(createFn: () => Validator<T>);
|
|
19
|
+
create(): Validator<T>;
|
|
15
20
|
}
|
|
16
21
|
export declare class Validator<T = any> {
|
|
17
22
|
options?: ValidatorOptions;
|
|
@@ -28,4 +33,3 @@ export declare class Validator<T = any> {
|
|
|
28
33
|
add(validatorEntry: ValidatorEntry): void;
|
|
29
34
|
validate(object: T, options?: ValidatorOptions): Promise<Misfit[]>;
|
|
30
35
|
}
|
|
31
|
-
export {};
|
package/lib/lib/Validator.js
CHANGED
|
@@ -9,14 +9,21 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.Validator = void 0;
|
|
12
|
+
exports.Validator = exports.SimpleValidatorFactory = void 0;
|
|
13
13
|
const knight_log_1 = require("knight-log");
|
|
14
14
|
const Constraint_1 = require("./Constraint");
|
|
15
15
|
const DotNotation_1 = require("./DotNotation");
|
|
16
16
|
const QuickConstraint_1 = require("./constraints/QuickConstraint");
|
|
17
17
|
let log = new knight_log_1.Log('knight-validation/Validator.ts');
|
|
18
|
-
class
|
|
18
|
+
class SimpleValidatorFactory {
|
|
19
|
+
constructor(createFn) {
|
|
20
|
+
this.createFn = createFn;
|
|
21
|
+
}
|
|
22
|
+
create() {
|
|
23
|
+
return this.createFn();
|
|
24
|
+
}
|
|
19
25
|
}
|
|
26
|
+
exports.SimpleValidatorFactory = SimpleValidatorFactory;
|
|
20
27
|
class Validator {
|
|
21
28
|
constructor(options) {
|
|
22
29
|
this.entries = [];
|