thesimplevalidation 1.0.1 → 1.0.2
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/README.md +0 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +17 -6
- package/dist/index.js.map +1 -1
- package/dist/src/index.d.ts +8 -8
- package/dist/src/index.js +22 -10
- package/dist/src/index.js.map +1 -1
- package/dist/src/validation-errors-model.d.ts +3 -3
- package/dist/src/validation-errors-model.js +2 -2
- package/dist/src/validation-model.d.ts +3 -3
- package/dist/src/validation-model.js +2 -2
- package/dist/src/validation-property-result.d.ts +4 -4
- package/dist/src/validation-property-result.js +2 -2
- package/dist/src/validation-result.d.ts +8 -8
- package/dist/src/validation-result.js +2 -2
- package/dist/src/validation-scope.d.ts +19 -19
- package/dist/src/validation-scope.js +199 -196
- package/dist/src/validation-scope.js.map +1 -1
- package/dist/src/validator-setup.d.ts +4 -4
- package/dist/src/validator-setup.js +2 -2
- package/dist/src/validator.d.ts +8 -8
- package/dist/src/validator.js +68 -67
- package/dist/src/validator.js.map +1 -1
- package/dist/src/validators/boolean/index.d.ts +10 -10
- package/dist/src/validators/boolean/index.js +79 -76
- package/dist/src/validators/boolean/index.js.map +1 -1
- package/dist/src/validators/index.d.ts +5 -5
- package/dist/src/validators/index.js +13 -12
- package/dist/src/validators/index.js.map +1 -1
- package/dist/src/validators/max/index.d.ts +10 -10
- package/dist/src/validators/max/index.js +87 -84
- package/dist/src/validators/max/index.js.map +1 -1
- package/dist/src/validators/min/index.d.ts +10 -10
- package/dist/src/validators/min/index.js +88 -85
- package/dist/src/validators/min/index.js.map +1 -1
- package/dist/src/validators/required/index.d.ts +7 -7
- package/dist/src/validators/required/index.js +83 -80
- package/dist/src/validators/required/index.js.map +1 -1
- package/dist/src/validators/simple/index.d.ts +10 -10
- package/dist/src/validators/simple/index.js +75 -72
- package/dist/src/validators/simple/index.js.map +1 -1
- package/package.json +10 -13
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validation-scope.js","sourceRoot":"","sources":["../../src/validation-scope.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"validation-scope.js","sourceRoot":"","sources":["../../src/validation-scope.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,sEAAyC;AACzC,0DAA6B;AAC7B,kEAAqC;AACrC,4DAA+B;AAK/B;IAQI,yBAAoB,KAInB;QAJD,iBAOC;QAPmB,UAAK,GAAL,KAAK,CAIxB;QAKM,gBAAW,GAAG,UAAC,KAAa;YAC/B,KAAI,CAAC,aAAa,GAAG,IAAA,0BAAS,EAAC,KAAK,CAAC,CAAC;YACtC,OAAO,KAAI,CAAC;QAChB,CAAC,CAAA;QAEM,kBAAa,GAAG,UAAyB,GAAM;YAAE,oBAA0C;iBAA1C,UAA0C,EAA1C,qBAA0C,EAA1C,IAA0C;gBAA1C,mCAA0C;;YAC9F,KAAI,CAAC,SAAS,CAAC,GAAG,CAAC,GAAG;gBAClB,UAAU,EAAE,UAAU;aACzB,CAAC;YACF,OAAO,KAAI,CAAC;QAChB,CAAC,CAAA;QAEM,oBAAe,GAAG,UAAC,KAAmB,EAAE,GAAyB;YAAzB,oBAAA,EAAA,UAAyB;YACpE,IAAM,KAAK,GAAW,KAAI,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC;YAC5C,IAAM,aAAa,GAAG,KAAI,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;YAChD,IAAM,UAAU,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC;YAChC,IAAI,KAAK,CAAC,OAAO,CAAC,aAAa,CAAC,IAAI,KAAK,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE;gBAC3D,IAAI,aAAa,CAAC,MAAM,KAAK,UAAU,CAAC,MAAM;oBAAE,OAAO,IAAI,CAAC;gBAC5D,KAAK,IAAI,KAAK,GAAG,CAAC,EAAE,KAAK,GAAG,aAAa,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B;4BACtC,OAAO,EAAE,IAAI;4BACb,MAAM,EAAE,EAAE;4BACV,UAAU,EAAE,EAEX;yBACyB,CAAC;8BAEE,EAAV,yBAAU;;;6BAAV,CAAA,wBAAU,CAAA;wBAAtB,QAAQ;wBAC6C,qBAAM,IAAI,CAAC,eAAe,CAAC,QAAQ,CAAC,EAAA;;wBAA1F,wBAAwB,GAA8B,SAAoC;wBAChG,MAAM,CAAC,OAAO,GAAG,MAAM,CAAC,OAAO,IAAI,wBAAwB,CAAC,OAAO,CAAC;wBACpE,MAAM,CAAC,UAAU,CAAC,QAAQ,CAAC,GAAG,wBAAwB,CAAC;wBACvD,IAAI,CAAC,wBAAwB,CAAC,OAAO;4BAAE,MAAM,CAAC,MAAM,mCAAO,MAAM,CAAC,MAAM,SAAK,wBAAwB,CAAC,MAAM,OAAC,CAAC;;;wBAJ3F,IAAU,CAAA;;;6BAO7B,CAAA,IAAI,CAAC,KAAK,CAAC,mBAAmB,IAAI,IAAI,CAAA,EAAtC,wBAAsC;wBAAE,qBAAM,IAAI,CAAC,KAAK,CAAC,mBAAmB,CAAC,MAAM,CAAC,EAAA;;wBAA5C,SAA4C,CAAC;;4BAEzF,sBAAO,MAAM,EAAC;;;aACjB,CAAA;QAhGG,IAAI,CAAC,aAAa,GAAG,IAAA,0BAAS,EAAC,KAAK,CAAC,QAAQ,EAAE,CAAC,CAAC;QACjD,IAAI,CAAC,SAAS,GAAG,EAAS,CAAC;IAC/B,CAAC;IA+FL,sBAAC;AAAD,CAAC,AA9GD,IA8GC;AA9GY,0CAAe"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export interface IValidatorSetup<TModel, K extends keyof TModel> {
|
|
2
|
-
isDisabled?: (value: TModel[K]) => boolean;
|
|
3
|
-
getErrors?: (value: TModel[K]) => string[];
|
|
4
|
-
}
|
|
1
|
+
export interface IValidatorSetup<TModel, K extends keyof TModel> {
|
|
2
|
+
isDisabled?: (value: TModel[K]) => boolean;
|
|
3
|
+
getErrors?: (value: TModel[K]) => string[];
|
|
4
|
+
}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
//# sourceMappingURL=validator-setup.js.map
|
package/dist/src/validator.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { IValidationPropertyResult } from "./validation-property-result";
|
|
2
|
-
import { IValidatorSetup } from "./validator-setup";
|
|
3
|
-
export declare abstract class Validator<TModel, K extends keyof TModel, TSetup extends IValidatorSetup<TModel, K> = IValidatorSetup<TModel, K>> {
|
|
4
|
-
protected setup: TSetup;
|
|
5
|
-
constructor(setup: TSetup);
|
|
6
|
-
isValid: (value: TModel[K], model: TModel, field: K) => Promise<IValidationPropertyResult>;
|
|
7
|
-
protected abstract isValidInternal(value: TModel[K], model: TModel, field: K): Promise<IValidationPropertyResult>;
|
|
8
|
-
}
|
|
1
|
+
import { IValidationPropertyResult } from "./validation-property-result";
|
|
2
|
+
import { IValidatorSetup } from "./validator-setup";
|
|
3
|
+
export declare abstract class Validator<TModel, K extends keyof TModel, TSetup extends IValidatorSetup<TModel, K> = IValidatorSetup<TModel, K>> {
|
|
4
|
+
protected setup: TSetup;
|
|
5
|
+
constructor(setup: TSetup);
|
|
6
|
+
isValid: (value: TModel[K], model: TModel, field: K) => Promise<IValidationPropertyResult>;
|
|
7
|
+
protected abstract isValidInternal(value: TModel[K], model: TModel, field: K): Promise<IValidationPropertyResult>;
|
|
8
|
+
}
|
package/dist/src/validator.js
CHANGED
|
@@ -1,68 +1,69 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
-
function step(op) {
|
|
16
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
-
while (_) try {
|
|
18
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
-
switch (op[0]) {
|
|
21
|
-
case 0: case 1: t = op; break;
|
|
22
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
-
default:
|
|
26
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
-
if (t[2]) _.ops.pop();
|
|
31
|
-
_.trys.pop(); continue;
|
|
32
|
-
}
|
|
33
|
-
op = body.call(thisArg, _);
|
|
34
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
this.
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
+
function step(op) {
|
|
16
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
+
switch (op[0]) {
|
|
21
|
+
case 0: case 1: t = op; break;
|
|
22
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
+
default:
|
|
26
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
+
if (t[2]) _.ops.pop();
|
|
31
|
+
_.trys.pop(); continue;
|
|
32
|
+
}
|
|
33
|
+
op = body.call(thisArg, _);
|
|
34
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.Validator = void 0;
|
|
40
|
+
var Validator = /** @class */ (function () {
|
|
41
|
+
function Validator(setup) {
|
|
42
|
+
var _this = this;
|
|
43
|
+
this.setup = setup;
|
|
44
|
+
this.isValid = function (value, model, field) { return __awaiter(_this, void 0, void 0, function () {
|
|
45
|
+
var result;
|
|
46
|
+
return __generator(this, function (_a) {
|
|
47
|
+
switch (_a.label) {
|
|
48
|
+
case 0:
|
|
49
|
+
if (this.setup.isDisabled != null && this.setup.isDisabled(value)) {
|
|
50
|
+
return [2 /*return*/, {
|
|
51
|
+
isValid: true,
|
|
52
|
+
errors: []
|
|
53
|
+
}];
|
|
54
|
+
}
|
|
55
|
+
return [4 /*yield*/, this.isValidInternal(value, model, field)];
|
|
56
|
+
case 1:
|
|
57
|
+
result = _a.sent();
|
|
58
|
+
if (result.isValid !== true && this.setup.getErrors != null) {
|
|
59
|
+
result.errors = this.setup.getErrors(value);
|
|
60
|
+
}
|
|
61
|
+
return [2 /*return*/, result];
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
}); };
|
|
65
|
+
}
|
|
66
|
+
return Validator;
|
|
67
|
+
}());
|
|
68
|
+
exports.Validator = Validator;
|
|
68
69
|
//# sourceMappingURL=validator.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validator.js","sourceRoot":"","sources":["../../src/validator.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"validator.js","sourceRoot":"","sources":["../../src/validator.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGA;IAEI,mBAAsB,KAAa;QAAnC,iBAAwC;QAAlB,UAAK,GAAL,KAAK,CAAQ;QAE5B,YAAO,GAAG,UAAO,KAAgB,EAAE,KAAa,EAAE,KAAQ;;;;;wBAC7D,IAAI,IAAI,CAAC,KAAK,CAAC,UAAU,IAAI,IAAI,IAAI,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,KAAK,CAAC,EAAE;4BAC/D,sBAAO;oCACH,OAAO,EAAE,IAAI;oCACb,MAAM,EAAE,EAAE;iCACb,EAAC;yBACL;wBAEyC,qBAAM,IAAI,CAAC,eAAe,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,CAAC,EAAA;;wBAAnF,MAAM,GAA8B,SAA+C;wBACzF,IAAI,MAAM,CAAC,OAAO,KAAK,IAAI,IAAI,IAAI,CAAC,KAAK,CAAC,SAAS,IAAI,IAAI,EAAE;4BACzD,MAAM,CAAC,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;yBAC/C;wBAED,sBAAO,MAAM,EAAC;;;aACjB,CAAA;IAhBsC,CAAC;IAmB5C,gBAAC;AAAD,CAAC,AArBD,IAqBC;AArBqB,8BAAS"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { IValidationPropertyResult } from "../../validation-property-result";
|
|
2
|
-
import { IValidatorSetup } from "../../validator-setup";
|
|
3
|
-
import { Validator } from "../../validator";
|
|
4
|
-
export interface IBooleanValidatorSetup<TModel, K extends keyof TModel> extends IValidatorSetup<TModel, K> {
|
|
5
|
-
target: () => boolean;
|
|
6
|
-
}
|
|
7
|
-
export declare class BooleanValidator<TModel, K extends keyof TModel> extends Validator<TModel, K, IBooleanValidatorSetup<TModel, K>> {
|
|
8
|
-
constructor(setup: IBooleanValidatorSetup<TModel, K>);
|
|
9
|
-
isValidInternal(value: TModel[K]): Promise<IValidationPropertyResult>;
|
|
10
|
-
}
|
|
1
|
+
import { IValidationPropertyResult } from "../../validation-property-result";
|
|
2
|
+
import { IValidatorSetup } from "../../validator-setup";
|
|
3
|
+
import { Validator } from "../../validator";
|
|
4
|
+
export interface IBooleanValidatorSetup<TModel, K extends keyof TModel> extends IValidatorSetup<TModel, K> {
|
|
5
|
+
target: () => boolean;
|
|
6
|
+
}
|
|
7
|
+
export declare class BooleanValidator<TModel, K extends keyof TModel> extends Validator<TModel, K, IBooleanValidatorSetup<TModel, K>> {
|
|
8
|
+
constructor(setup: IBooleanValidatorSetup<TModel, K>);
|
|
9
|
+
isValidInternal(value: TModel[K]): Promise<IValidationPropertyResult>;
|
|
10
|
+
}
|
|
@@ -1,77 +1,80 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __extends = (this && this.__extends) || (function () {
|
|
3
|
-
var extendStatics = function (d, b) {
|
|
4
|
-
extendStatics = Object.setPrototypeOf ||
|
|
5
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
-
function (d, b) { for (var p in b) if (
|
|
7
|
-
return extendStatics(d, b);
|
|
8
|
-
};
|
|
9
|
-
return function (d, b) {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
d
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
function
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
function
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
case
|
|
37
|
-
case
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
if (
|
|
42
|
-
if (t &&
|
|
43
|
-
if (t[
|
|
44
|
-
_.
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
return
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
}
|
|
76
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __extends = (this && this.__extends) || (function () {
|
|
3
|
+
var extendStatics = function (d, b) {
|
|
4
|
+
extendStatics = Object.setPrototypeOf ||
|
|
5
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
+
return extendStatics(d, b);
|
|
8
|
+
};
|
|
9
|
+
return function (d, b) {
|
|
10
|
+
if (typeof b !== "function" && b !== null)
|
|
11
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
+
extendStatics(d, b);
|
|
13
|
+
function __() { this.constructor = d; }
|
|
14
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
+
};
|
|
16
|
+
})();
|
|
17
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
18
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
19
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
20
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
21
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
22
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
23
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
24
|
+
});
|
|
25
|
+
};
|
|
26
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
27
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
28
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
29
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
30
|
+
function step(op) {
|
|
31
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
32
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
33
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
34
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
35
|
+
switch (op[0]) {
|
|
36
|
+
case 0: case 1: t = op; break;
|
|
37
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
38
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
39
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
40
|
+
default:
|
|
41
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
42
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
43
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
44
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
45
|
+
if (t[2]) _.ops.pop();
|
|
46
|
+
_.trys.pop(); continue;
|
|
47
|
+
}
|
|
48
|
+
op = body.call(thisArg, _);
|
|
49
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
50
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
54
|
+
exports.BooleanValidator = void 0;
|
|
55
|
+
var validator_1 = require("../../validator");
|
|
56
|
+
var BooleanValidator = /** @class */ (function (_super) {
|
|
57
|
+
__extends(BooleanValidator, _super);
|
|
58
|
+
function BooleanValidator(setup) {
|
|
59
|
+
return _super.call(this, setup) || this;
|
|
60
|
+
}
|
|
61
|
+
BooleanValidator.prototype.isValidInternal = function (value) {
|
|
62
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
63
|
+
var isValid, targetValue;
|
|
64
|
+
return __generator(this, function (_a) {
|
|
65
|
+
isValid = true;
|
|
66
|
+
targetValue = this.setup.target();
|
|
67
|
+
if (value != null && typeof value === "boolean") {
|
|
68
|
+
isValid = targetValue === value;
|
|
69
|
+
}
|
|
70
|
+
return [2 /*return*/, {
|
|
71
|
+
isValid: isValid,
|
|
72
|
+
errors: []
|
|
73
|
+
}];
|
|
74
|
+
});
|
|
75
|
+
});
|
|
76
|
+
};
|
|
77
|
+
return BooleanValidator;
|
|
78
|
+
}(validator_1.Validator));
|
|
79
|
+
exports.BooleanValidator = BooleanValidator;
|
|
77
80
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/validators/boolean/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/validators/boolean/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,6CAA4C;AAM5C;IAAsE,oCAAuD;IACzH,0BAAY,KAAwC;eAChD,kBAAM,KAAK,CAAC;IAChB,CAAC;IAEY,0CAAe,GAA5B,UAA6B,KAAgB;;;;gBACrC,OAAO,GAAY,IAAI,CAAC;gBACtB,WAAW,GAAY,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC;gBAEjD,IAAI,KAAK,IAAI,IAAI,IAAI,OAAO,KAAK,KAAK,SAAS,EAAE;oBAC7C,OAAO,GAAG,WAAW,KAAK,KAAK,CAAC;iBACnC;gBAED,sBAAO;wBACH,OAAO,EAAE,OAAO;wBAChB,MAAM,EAAE,EAAE;qBACb,EAAC;;;KACL;IACL,uBAAC;AAAD,CAAC,AAlBD,CAAsE,qBAAS,GAkB9E;AAlBY,4CAAgB"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { SimpleValidator, ISimpleValidatorSetup } from "./simple";
|
|
2
|
-
export { BooleanValidator, IBooleanValidatorSetup } from "./boolean";
|
|
3
|
-
export { RequiredValidator } from "./required";
|
|
4
|
-
export { MinValidator, IMinValidatorSetup } from "./min";
|
|
5
|
-
export { MaxValidator, IMaxValidatorSetup } from "./max";
|
|
1
|
+
export { SimpleValidator, ISimpleValidatorSetup } from "./simple";
|
|
2
|
+
export { BooleanValidator, IBooleanValidatorSetup } from "./boolean";
|
|
3
|
+
export { RequiredValidator } from "./required";
|
|
4
|
+
export { MinValidator, IMinValidatorSetup } from "./min";
|
|
5
|
+
export { MaxValidator, IMaxValidatorSetup } from "./max";
|
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MaxValidator = exports.MinValidator = exports.RequiredValidator = exports.BooleanValidator = exports.SimpleValidator = void 0;
|
|
4
|
+
var simple_1 = require("./simple");
|
|
5
|
+
Object.defineProperty(exports, "SimpleValidator", { enumerable: true, get: function () { return simple_1.SimpleValidator; } });
|
|
6
|
+
var boolean_1 = require("./boolean");
|
|
7
|
+
Object.defineProperty(exports, "BooleanValidator", { enumerable: true, get: function () { return boolean_1.BooleanValidator; } });
|
|
8
|
+
var required_1 = require("./required");
|
|
9
|
+
Object.defineProperty(exports, "RequiredValidator", { enumerable: true, get: function () { return required_1.RequiredValidator; } });
|
|
10
|
+
var min_1 = require("./min");
|
|
11
|
+
Object.defineProperty(exports, "MinValidator", { enumerable: true, get: function () { return min_1.MinValidator; } });
|
|
12
|
+
var max_1 = require("./max");
|
|
13
|
+
Object.defineProperty(exports, "MaxValidator", { enumerable: true, get: function () { return max_1.MaxValidator; } });
|
|
13
14
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/validators/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/validators/index.ts"],"names":[],"mappings":";;;AAAA,mCAAkE;AAAzD,yGAAA,eAAe,OAAA;AACxB,qCAAqE;AAA5D,2GAAA,gBAAgB,OAAA;AACzB,uCAA+C;AAAtC,6GAAA,iBAAiB,OAAA;AAC1B,6BAAyD;AAAhD,mGAAA,YAAY,OAAA;AACrB,6BAAyD;AAAhD,mGAAA,YAAY,OAAA"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { IValidatorSetup } from "../../validator-setup";
|
|
2
|
-
import { IValidationPropertyResult } from "../../validation-property-result";
|
|
3
|
-
import { Validator } from "../../validator";
|
|
4
|
-
export interface IMaxValidatorSetup<TModel, K extends keyof TModel> extends IValidatorSetup<TModel, K> {
|
|
5
|
-
maxValue: () => number;
|
|
6
|
-
}
|
|
7
|
-
export declare class MaxValidator<TModel, K extends keyof TModel> extends Validator<TModel, K, IMaxValidatorSetup<TModel, K>> {
|
|
8
|
-
constructor(setup: IMaxValidatorSetup<TModel, K>);
|
|
9
|
-
isValidInternal(value: TModel[K]): Promise<IValidationPropertyResult>;
|
|
10
|
-
}
|
|
1
|
+
import { IValidatorSetup } from "../../validator-setup";
|
|
2
|
+
import { IValidationPropertyResult } from "../../validation-property-result";
|
|
3
|
+
import { Validator } from "../../validator";
|
|
4
|
+
export interface IMaxValidatorSetup<TModel, K extends keyof TModel> extends IValidatorSetup<TModel, K> {
|
|
5
|
+
maxValue: () => number;
|
|
6
|
+
}
|
|
7
|
+
export declare class MaxValidator<TModel, K extends keyof TModel> extends Validator<TModel, K, IMaxValidatorSetup<TModel, K>> {
|
|
8
|
+
constructor(setup: IMaxValidatorSetup<TModel, K>);
|
|
9
|
+
isValidInternal(value: TModel[K]): Promise<IValidationPropertyResult>;
|
|
10
|
+
}
|