@decaf-ts/decorator-validation 1.5.8 → 1.5.10
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/LICENSE.md +0 -0
- package/README.md +0 -0
- package/dist/decorator-validation.js +1 -1
- package/dist/decorator-validation.js.LICENSE.txt +0 -0
- package/dist/esm/decorator-validation.js +1 -1
- package/dist/esm/decorator-validation.js.LICENSE.txt +0 -0
- package/{lib/esm → dist/types}/index.d.ts +1 -1
- package/{lib/esm → dist/types}/model/Model.d.ts +1 -0
- package/{lib/esm → dist/types}/model/ModelErrorDefinition.d.ts +0 -0
- package/{lib/esm → dist/types}/model/constants.d.ts +0 -0
- package/{lib/esm → dist/types}/model/construction.d.ts +0 -0
- package/{lib/esm → dist/types}/model/decorators.d.ts +0 -0
- package/{lib/esm → dist/types}/model/index.d.ts +0 -1
- package/{lib/esm → dist/types}/model/types.d.ts +0 -0
- package/{lib/esm → dist/types}/model/validation.d.ts +0 -0
- package/{lib/esm → dist/types}/utils/constants.d.ts +0 -0
- package/{lib/esm → dist/types}/utils/dates.d.ts +0 -0
- package/{lib/esm → dist/types}/utils/decorators.d.ts +0 -0
- package/{lib → dist/types}/utils/hashing.d.ts +0 -14
- package/{lib → dist/types}/utils/index.d.ts +1 -0
- package/{lib/esm → dist/types}/utils/registry.d.ts +0 -0
- package/{lib → dist/types}/utils/serialization.d.ts +4 -30
- package/{lib/esm → dist/types}/utils/strings.d.ts +0 -0
- package/dist/types/utils/types.d.ts +29 -0
- package/{lib → dist/types}/validation/Validation.d.ts +1 -1
- package/{lib → dist/types}/validation/Validators/DateValidator.d.ts +1 -1
- package/{lib → dist/types}/validation/Validators/EmailValidator.d.ts +1 -1
- package/{lib → dist/types}/validation/Validators/ListValidator.d.ts +1 -1
- package/{lib → dist/types}/validation/Validators/MaxLengthValidator.d.ts +1 -1
- package/{lib/esm → dist/types}/validation/Validators/MaxValidator.d.ts +1 -1
- package/{lib/esm → dist/types}/validation/Validators/MinLengthValidator.d.ts +1 -1
- package/{lib/esm → dist/types}/validation/Validators/MinValidator.d.ts +1 -1
- package/{lib/esm → dist/types}/validation/Validators/PasswordValidator.d.ts +1 -1
- package/{lib → dist/types}/validation/Validators/PatternValidator.d.ts +1 -1
- package/{lib/esm → dist/types}/validation/Validators/RequiredValidator.d.ts +1 -1
- package/{lib/esm → dist/types}/validation/Validators/StepValidator.d.ts +1 -1
- package/{lib → dist/types}/validation/Validators/TypeValidator.d.ts +1 -1
- package/{lib/esm → dist/types}/validation/Validators/URLValidator.d.ts +1 -1
- package/{lib/esm → dist/types}/validation/Validators/Validator.d.ts +1 -1
- package/{lib/esm → dist/types}/validation/Validators/ValidatorRegistry.d.ts +2 -2
- package/{lib/esm → dist/types}/validation/Validators/constants.d.ts +0 -0
- package/{lib/esm → dist/types}/validation/Validators/decorators.d.ts +0 -0
- package/dist/types/validation/Validators/index.d.ts +17 -0
- package/{lib/esm → dist/types}/validation/decorators.d.ts +0 -0
- package/{lib/esm → dist/types}/validation/index.d.ts +0 -0
- package/{lib/validation/Validators → dist/types/validation}/types.d.ts +49 -3
- package/lib/esm/index.js +3 -1
- package/lib/esm/model/Model.js +8 -1
- package/lib/esm/model/ModelErrorDefinition.js +2 -0
- package/lib/esm/model/constants.js +2 -0
- package/lib/esm/model/construction.js +2 -0
- package/lib/esm/model/decorators.js +2 -0
- package/lib/esm/model/index.js +2 -1
- package/lib/esm/model/types.js +2 -0
- package/lib/esm/model/validation.js +2 -0
- package/lib/esm/utils/constants.js +2 -0
- package/lib/esm/utils/dates.js +2 -0
- package/lib/esm/utils/decorators.js +2 -0
- package/lib/esm/utils/hashing.js +2 -17
- package/lib/esm/utils/index.js +3 -0
- package/lib/esm/utils/registry.js +2 -0
- package/lib/esm/utils/serialization.js +4 -1
- package/lib/esm/utils/strings.js +2 -0
- package/lib/esm/utils/types.js +3 -0
- package/lib/esm/validation/Validation.js +2 -0
- package/lib/esm/validation/Validators/DateValidator.js +2 -0
- package/lib/esm/validation/Validators/EmailValidator.js +2 -0
- package/lib/esm/validation/Validators/ListValidator.js +2 -0
- package/lib/esm/validation/Validators/MaxLengthValidator.js +2 -0
- package/lib/esm/validation/Validators/MaxValidator.js +2 -0
- package/lib/esm/validation/Validators/MinLengthValidator.js +2 -0
- package/lib/esm/validation/Validators/MinValidator.js +2 -0
- package/lib/esm/validation/Validators/PasswordValidator.js +2 -0
- package/lib/esm/validation/Validators/PatternValidator.js +2 -0
- package/lib/esm/validation/Validators/RequiredValidator.js +2 -0
- package/lib/esm/validation/Validators/StepValidator.js +2 -0
- package/lib/esm/validation/Validators/TypeValidator.js +2 -0
- package/lib/esm/validation/Validators/URLValidator.js +2 -0
- package/lib/esm/validation/Validators/Validator.js +2 -0
- package/lib/esm/validation/Validators/ValidatorRegistry.js +2 -0
- package/lib/esm/validation/Validators/constants.js +2 -0
- package/lib/esm/validation/Validators/decorators.js +2 -0
- package/lib/esm/validation/Validators/index.js +2 -35
- package/lib/esm/validation/decorators.js +2 -0
- package/lib/esm/validation/index.js +2 -0
- package/lib/esm/validation/types.js +2 -0
- package/lib/index.cjs +61 -0
- package/lib/model/Model.cjs +397 -0
- package/lib/model/ModelErrorDefinition.cjs +58 -0
- package/lib/model/constants.cjs +74 -0
- package/lib/model/construction.cjs +70 -0
- package/lib/model/decorators.cjs +69 -0
- package/lib/model/index.cjs +25 -0
- package/lib/model/types.cjs +4 -0
- package/lib/model/validation.cjs +140 -0
- package/lib/utils/constants.cjs +32 -0
- package/lib/utils/dates.cjs +253 -0
- package/lib/utils/decorators.cjs +24 -0
- package/lib/utils/hashing.cjs +90 -0
- package/lib/utils/index.cjs +26 -0
- package/lib/utils/registry.cjs +4 -0
- package/lib/utils/serialization.cjs +96 -0
- package/lib/utils/strings.cjs +37 -0
- package/lib/utils/types.cjs +4 -0
- package/lib/validation/Validation.cjs +77 -0
- package/lib/validation/Validators/DateValidator.cjs +59 -0
- package/lib/validation/Validators/EmailValidator.cjs +55 -0
- package/lib/validation/Validators/ListValidator.cjs +72 -0
- package/lib/validation/Validators/MaxLengthValidator.cjs +57 -0
- package/lib/validation/Validators/MaxValidator.cjs +62 -0
- package/lib/validation/Validators/MinLengthValidator.cjs +57 -0
- package/lib/validation/Validators/MinValidator.cjs +62 -0
- package/lib/validation/Validators/PasswordValidator.cjs +55 -0
- package/lib/validation/Validators/PatternValidator.cjs +75 -0
- package/lib/validation/Validators/RequiredValidator.cjs +62 -0
- package/lib/validation/Validators/StepValidator.cjs +57 -0
- package/lib/validation/Validators/TypeValidator.cjs +65 -0
- package/lib/validation/Validators/URLValidator.cjs +54 -0
- package/lib/validation/Validators/Validator.cjs +53 -0
- package/lib/validation/Validators/ValidatorRegistry.cjs +87 -0
- package/lib/validation/Validators/constants.cjs +139 -0
- package/lib/validation/Validators/decorators.cjs +30 -0
- package/lib/validation/Validators/index.cjs +35 -0
- package/lib/validation/decorators.cjs +306 -0
- package/lib/validation/{index.js → index.cjs} +6 -4
- package/lib/validation/types.cjs +4 -0
- package/package.json +2 -2
- package/lib/esm/model/utils.d.ts +0 -2
- package/lib/esm/model/utils.js +0 -8
- package/lib/esm/utils/hashing.d.ts +0 -52
- package/lib/esm/utils/index.d.ts +0 -7
- package/lib/esm/utils/serialization.d.ts +0 -79
- package/lib/esm/validation/Validation.d.ts +0 -51
- package/lib/esm/validation/Validators/DateValidator.d.ts +0 -28
- package/lib/esm/validation/Validators/EmailValidator.d.ts +0 -28
- package/lib/esm/validation/Validators/ListValidator.d.ts +0 -28
- package/lib/esm/validation/Validators/MaxLengthValidator.d.ts +0 -29
- package/lib/esm/validation/Validators/PatternValidator.d.ts +0 -37
- package/lib/esm/validation/Validators/TypeValidator.d.ts +0 -25
- package/lib/esm/validation/Validators/index.d.ts +0 -52
- package/lib/esm/validation/Validators/types.js +0 -1
- package/lib/esm/validation/types.d.ts +0 -46
- package/lib/index.d.ts +0 -42
- package/lib/index.js +0 -59
- package/lib/model/Model.d.ts +0 -203
- package/lib/model/Model.js +0 -389
- package/lib/model/ModelErrorDefinition.d.ts +0 -22
- package/lib/model/ModelErrorDefinition.js +0 -56
- package/lib/model/constants.d.ts +0 -56
- package/lib/model/constants.js +0 -72
- package/lib/model/construction.d.ts +0 -29
- package/lib/model/construction.js +0 -68
- package/lib/model/decorators.d.ts +0 -25
- package/lib/model/decorators.js +0 -67
- package/lib/model/index.d.ts +0 -8
- package/lib/model/index.js +0 -24
- package/lib/model/types.d.ts +0 -79
- package/lib/model/types.js +0 -2
- package/lib/model/utils.d.ts +0 -2
- package/lib/model/utils.js +0 -11
- package/lib/model/validation.d.ts +0 -14
- package/lib/model/validation.js +0 -138
- package/lib/utils/constants.d.ts +0 -26
- package/lib/utils/constants.js +0 -30
- package/lib/utils/dates.d.ts +0 -76
- package/lib/utils/dates.js +0 -251
- package/lib/utils/decorators.d.ts +0 -2
- package/lib/utils/decorators.js +0 -22
- package/lib/utils/hashing.js +0 -106
- package/lib/utils/index.js +0 -23
- package/lib/utils/registry.d.ts +0 -68
- package/lib/utils/registry.js +0 -2
- package/lib/utils/serialization.js +0 -93
- package/lib/utils/strings.d.ts +0 -25
- package/lib/utils/strings.js +0 -35
- package/lib/validation/Validation.js +0 -75
- package/lib/validation/Validators/DateValidator.js +0 -57
- package/lib/validation/Validators/EmailValidator.js +0 -53
- package/lib/validation/Validators/ListValidator.js +0 -70
- package/lib/validation/Validators/MaxLengthValidator.js +0 -55
- package/lib/validation/Validators/MaxValidator.d.ts +0 -28
- package/lib/validation/Validators/MaxValidator.js +0 -60
- package/lib/validation/Validators/MinLengthValidator.d.ts +0 -29
- package/lib/validation/Validators/MinLengthValidator.js +0 -55
- package/lib/validation/Validators/MinValidator.d.ts +0 -28
- package/lib/validation/Validators/MinValidator.js +0 -60
- package/lib/validation/Validators/PasswordValidator.d.ts +0 -28
- package/lib/validation/Validators/PasswordValidator.js +0 -53
- package/lib/validation/Validators/PatternValidator.js +0 -73
- package/lib/validation/Validators/RequiredValidator.d.ts +0 -28
- package/lib/validation/Validators/RequiredValidator.js +0 -60
- package/lib/validation/Validators/StepValidator.d.ts +0 -29
- package/lib/validation/Validators/StepValidator.js +0 -55
- package/lib/validation/Validators/TypeValidator.js +0 -63
- package/lib/validation/Validators/URLValidator.d.ts +0 -27
- package/lib/validation/Validators/URLValidator.js +0 -52
- package/lib/validation/Validators/Validator.d.ts +0 -41
- package/lib/validation/Validators/Validator.js +0 -51
- package/lib/validation/Validators/ValidatorRegistry.d.ts +0 -47
- package/lib/validation/Validators/ValidatorRegistry.js +0 -85
- package/lib/validation/Validators/constants.d.ts +0 -96
- package/lib/validation/Validators/constants.js +0 -137
- package/lib/validation/Validators/decorators.d.ts +0 -12
- package/lib/validation/Validators/decorators.js +0 -28
- package/lib/validation/Validators/index.d.ts +0 -52
- package/lib/validation/Validators/index.js +0 -69
- package/lib/validation/Validators/types.js +0 -2
- package/lib/validation/decorators.d.ts +0 -178
- package/lib/validation/decorators.js +0 -304
- package/lib/validation/index.d.ts +0 -4
- package/lib/validation/types.d.ts +0 -46
- package/lib/validation/types.js +0 -2
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Validation = void 0;
|
|
4
|
-
const ValidatorRegistry_1 = require("./Validators/ValidatorRegistry");
|
|
5
|
-
const constants_1 = require("./Validators/constants");
|
|
6
|
-
/**
|
|
7
|
-
* @summary Static class acting as a namespace for the Validation
|
|
8
|
-
*
|
|
9
|
-
* @class Validation
|
|
10
|
-
* @static
|
|
11
|
-
*
|
|
12
|
-
* @category Validation
|
|
13
|
-
*/
|
|
14
|
-
class Validation {
|
|
15
|
-
static { this.actingValidatorRegistry = undefined; }
|
|
16
|
-
constructor() { }
|
|
17
|
-
/**
|
|
18
|
-
* @summary Defines the acting ValidatorRegistry
|
|
19
|
-
*
|
|
20
|
-
* @param {IValidatorRegistry} validatorRegistry the new implementation of the validator Registry
|
|
21
|
-
* @param {function(Validator): Validator} [migrationHandler] the method to map the validator if required;
|
|
22
|
-
*/
|
|
23
|
-
static setRegistry(validatorRegistry, migrationHandler) {
|
|
24
|
-
if (migrationHandler && Validation.actingValidatorRegistry)
|
|
25
|
-
Validation.actingValidatorRegistry.getKeys().forEach((k) => {
|
|
26
|
-
const validator = validatorRegistry.get(k);
|
|
27
|
-
if (validator)
|
|
28
|
-
validatorRegistry.register(migrationHandler(validator));
|
|
29
|
-
});
|
|
30
|
-
Validation.actingValidatorRegistry = validatorRegistry;
|
|
31
|
-
}
|
|
32
|
-
/**
|
|
33
|
-
* @summary Returns the current ValidatorRegistry
|
|
34
|
-
*
|
|
35
|
-
* @return IValidatorRegistry, defaults to {@link ValidatorRegistry}
|
|
36
|
-
*/
|
|
37
|
-
static getRegistry() {
|
|
38
|
-
if (!Validation.actingValidatorRegistry)
|
|
39
|
-
Validation.actingValidatorRegistry = new ValidatorRegistry_1.ValidatorRegistry();
|
|
40
|
-
return Validation.actingValidatorRegistry;
|
|
41
|
-
}
|
|
42
|
-
/**
|
|
43
|
-
* @summary Retrieves a validator
|
|
44
|
-
*
|
|
45
|
-
* @param {string} validatorKey one of the {@link ValidationKeys}
|
|
46
|
-
* @return {Validator | undefined} the registered Validator or undefined if there is nono matching the provided key
|
|
47
|
-
*/
|
|
48
|
-
static get(validatorKey) {
|
|
49
|
-
return Validation.getRegistry().get(validatorKey);
|
|
50
|
-
}
|
|
51
|
-
/**
|
|
52
|
-
* @summary Registers the provided validators onto the registry
|
|
53
|
-
*
|
|
54
|
-
* @param {T[] | ValidatorDefinition[]} validator
|
|
55
|
-
*/
|
|
56
|
-
static register(...validator) {
|
|
57
|
-
return Validation.getRegistry().register(...validator);
|
|
58
|
-
}
|
|
59
|
-
/**
|
|
60
|
-
* @summary Builds the key to store as Metadata under Reflections
|
|
61
|
-
* @description concatenates {@link ValidationKeys#REFLECT} with the provided key
|
|
62
|
-
*
|
|
63
|
-
* @param {string} key
|
|
64
|
-
*/
|
|
65
|
-
static key(key) {
|
|
66
|
-
return constants_1.ValidationKeys.REFLECT + key;
|
|
67
|
-
}
|
|
68
|
-
/**
|
|
69
|
-
* @summary Returns all registered validation keys
|
|
70
|
-
*/
|
|
71
|
-
static keys() {
|
|
72
|
-
return this.getRegistry().getKeys();
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
exports.Validation = Validation;
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
-
};
|
|
8
|
-
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.DateValidator = void 0;
|
|
13
|
-
const Validator_1 = require("./Validator");
|
|
14
|
-
const constants_1 = require("./constants");
|
|
15
|
-
const decorators_1 = require("./decorators");
|
|
16
|
-
/**
|
|
17
|
-
* @summary Date Validator
|
|
18
|
-
*
|
|
19
|
-
* @param {string} [message] defaults to {@link DEFAULT_ERROR_MESSAGES#DATE}
|
|
20
|
-
*
|
|
21
|
-
* @class DateValidator
|
|
22
|
-
* @extends Validator
|
|
23
|
-
*
|
|
24
|
-
* @category Validators
|
|
25
|
-
*/
|
|
26
|
-
let DateValidator = class DateValidator extends Validator_1.Validator {
|
|
27
|
-
constructor(message = constants_1.DEFAULT_ERROR_MESSAGES.DATE) {
|
|
28
|
-
super(message, Number.name, Date.name, String.name);
|
|
29
|
-
}
|
|
30
|
-
/**
|
|
31
|
-
* @summary Validates a model
|
|
32
|
-
*
|
|
33
|
-
* @param {Date | string} value
|
|
34
|
-
* @param {DateValidatorOptions} [options]
|
|
35
|
-
*
|
|
36
|
-
* @return {string | undefined}
|
|
37
|
-
*
|
|
38
|
-
* @override
|
|
39
|
-
*
|
|
40
|
-
* @see Validator#hasErrors
|
|
41
|
-
*/
|
|
42
|
-
hasErrors(value, options = {}) {
|
|
43
|
-
if (value === undefined)
|
|
44
|
-
return;
|
|
45
|
-
if (typeof value === "string")
|
|
46
|
-
value = new Date(value);
|
|
47
|
-
if (Number.isNaN(value.getDate())) {
|
|
48
|
-
const { message = "" } = options;
|
|
49
|
-
return this.getMessage(message || this.message);
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
};
|
|
53
|
-
exports.DateValidator = DateValidator;
|
|
54
|
-
exports.DateValidator = DateValidator = __decorate([
|
|
55
|
-
(0, decorators_1.validator)(constants_1.ValidationKeys.DATE),
|
|
56
|
-
__metadata("design:paramtypes", [String])
|
|
57
|
-
], DateValidator);
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
-
};
|
|
8
|
-
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.EmailValidator = void 0;
|
|
13
|
-
const constants_1 = require("./constants");
|
|
14
|
-
const PatternValidator_1 = require("./PatternValidator");
|
|
15
|
-
const decorators_1 = require("./decorators");
|
|
16
|
-
/**
|
|
17
|
-
* @summary Email Validator
|
|
18
|
-
*
|
|
19
|
-
* @param {string} [message] defaults to {@link DEFAULT_ERROR_MESSAGES#EMAIL}
|
|
20
|
-
*
|
|
21
|
-
* @class EmailValidator
|
|
22
|
-
* @extends PatternValidator
|
|
23
|
-
*
|
|
24
|
-
* @category Validators
|
|
25
|
-
*/
|
|
26
|
-
let EmailValidator = class EmailValidator extends PatternValidator_1.PatternValidator {
|
|
27
|
-
constructor(message = constants_1.DEFAULT_ERROR_MESSAGES.EMAIL) {
|
|
28
|
-
super(message);
|
|
29
|
-
}
|
|
30
|
-
/**
|
|
31
|
-
* @summary Validates a model
|
|
32
|
-
*
|
|
33
|
-
* @param {string} value
|
|
34
|
-
* @param {PatternValidatorOptions} [options]
|
|
35
|
-
*
|
|
36
|
-
* @return {string | undefined}
|
|
37
|
-
*
|
|
38
|
-
* @override
|
|
39
|
-
*
|
|
40
|
-
* @see Validator#hasErrors
|
|
41
|
-
*/
|
|
42
|
-
hasErrors(value, options = {}) {
|
|
43
|
-
return super.hasErrors(value, {
|
|
44
|
-
...options,
|
|
45
|
-
pattern: options?.pattern || constants_1.DEFAULT_PATTERNS.EMAIL,
|
|
46
|
-
});
|
|
47
|
-
}
|
|
48
|
-
};
|
|
49
|
-
exports.EmailValidator = EmailValidator;
|
|
50
|
-
exports.EmailValidator = EmailValidator = __decorate([
|
|
51
|
-
(0, decorators_1.validator)(constants_1.ValidationKeys.EMAIL),
|
|
52
|
-
__metadata("design:paramtypes", [String])
|
|
53
|
-
], EmailValidator);
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
-
};
|
|
8
|
-
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.ListValidator = void 0;
|
|
13
|
-
const Validator_1 = require("./Validator");
|
|
14
|
-
const constants_1 = require("./constants");
|
|
15
|
-
const decorators_1 = require("./decorators");
|
|
16
|
-
/**
|
|
17
|
-
* @summary List Validator
|
|
18
|
-
*
|
|
19
|
-
* @param {string} [message] defaults to {@link DEFAULT_ERROR_MESSAGES#LIST}
|
|
20
|
-
*
|
|
21
|
-
* @class ListValidator
|
|
22
|
-
* @extends Validator
|
|
23
|
-
*
|
|
24
|
-
* @category Validators
|
|
25
|
-
*/
|
|
26
|
-
let ListValidator = class ListValidator extends Validator_1.Validator {
|
|
27
|
-
constructor(message = constants_1.DEFAULT_ERROR_MESSAGES.LIST) {
|
|
28
|
-
super(message, Array.name, Set.name);
|
|
29
|
-
}
|
|
30
|
-
/**
|
|
31
|
-
* @summary Validates a model
|
|
32
|
-
*
|
|
33
|
-
* @param {any[] | Set<any>} value
|
|
34
|
-
* @param {ListValidatorOptions} options
|
|
35
|
-
*
|
|
36
|
-
* @return {string | undefined}
|
|
37
|
-
*
|
|
38
|
-
* @override
|
|
39
|
-
*
|
|
40
|
-
* @see Validator#hasErrors
|
|
41
|
-
*/
|
|
42
|
-
hasErrors(value, options) {
|
|
43
|
-
if (!value || (Array.isArray(value) ? !value.length : !value.size))
|
|
44
|
-
return;
|
|
45
|
-
const clazz = Array.isArray(options.clazz)
|
|
46
|
-
? options.clazz
|
|
47
|
-
: [options.clazz];
|
|
48
|
-
let val, isValid = true;
|
|
49
|
-
for (let i = 0; i < (Array.isArray(value) ? value.length : value.size); i++) {
|
|
50
|
-
val = value[i];
|
|
51
|
-
switch (typeof val) {
|
|
52
|
-
case "object":
|
|
53
|
-
case "function":
|
|
54
|
-
isValid = clazz.includes(val.constructor?.name);
|
|
55
|
-
break;
|
|
56
|
-
default:
|
|
57
|
-
isValid = clazz.some((c) => typeof val === c.toLowerCase());
|
|
58
|
-
break;
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
return isValid
|
|
62
|
-
? undefined
|
|
63
|
-
: this.getMessage(options.message || this.message, clazz);
|
|
64
|
-
}
|
|
65
|
-
};
|
|
66
|
-
exports.ListValidator = ListValidator;
|
|
67
|
-
exports.ListValidator = ListValidator = __decorate([
|
|
68
|
-
(0, decorators_1.validator)(constants_1.ValidationKeys.LIST),
|
|
69
|
-
__metadata("design:paramtypes", [String])
|
|
70
|
-
], ListValidator);
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
-
};
|
|
8
|
-
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.MaxLengthValidator = void 0;
|
|
13
|
-
const Validator_1 = require("./Validator");
|
|
14
|
-
const constants_1 = require("./constants");
|
|
15
|
-
const decorators_1 = require("./decorators");
|
|
16
|
-
/**
|
|
17
|
-
* @summary Maximum Length Validator
|
|
18
|
-
* @description Validates strings and Arrays on their maximum length
|
|
19
|
-
*
|
|
20
|
-
* @param {string} [message] defaults to {@link DEFAULT_ERROR_MESSAGES#MAX_LENGTH}
|
|
21
|
-
*
|
|
22
|
-
* @class MinLengthValidator
|
|
23
|
-
* @extends Validator
|
|
24
|
-
*
|
|
25
|
-
* @category Validators
|
|
26
|
-
*/
|
|
27
|
-
let MaxLengthValidator = class MaxLengthValidator extends Validator_1.Validator {
|
|
28
|
-
constructor(message = constants_1.DEFAULT_ERROR_MESSAGES.MAX_LENGTH) {
|
|
29
|
-
super(message, String.name, Array.name);
|
|
30
|
-
}
|
|
31
|
-
/**
|
|
32
|
-
* @summary Validates a model
|
|
33
|
-
*
|
|
34
|
-
* @param {string} value
|
|
35
|
-
* @param {MaxLengthValidatorOptions} options
|
|
36
|
-
*
|
|
37
|
-
* @return {string | undefined}
|
|
38
|
-
*
|
|
39
|
-
* @override
|
|
40
|
-
*
|
|
41
|
-
* @see Validator#hasErrors
|
|
42
|
-
*/
|
|
43
|
-
hasErrors(value, options) {
|
|
44
|
-
if (typeof value === "undefined")
|
|
45
|
-
return;
|
|
46
|
-
return value.length > options.maxLength
|
|
47
|
-
? this.getMessage(options.message || this.message, options.maxLength)
|
|
48
|
-
: undefined;
|
|
49
|
-
}
|
|
50
|
-
};
|
|
51
|
-
exports.MaxLengthValidator = MaxLengthValidator;
|
|
52
|
-
exports.MaxLengthValidator = MaxLengthValidator = __decorate([
|
|
53
|
-
(0, decorators_1.validator)(constants_1.ValidationKeys.MAX_LENGTH),
|
|
54
|
-
__metadata("design:paramtypes", [String])
|
|
55
|
-
], MaxLengthValidator);
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { Validator } from "./Validator";
|
|
2
|
-
import { MaxValidatorOptions } from "./types";
|
|
3
|
-
/**
|
|
4
|
-
* @summary Max Validator
|
|
5
|
-
*
|
|
6
|
-
* @param {string} [message] defaults to {@link DEFAULT_ERROR_MESSAGES#MAX}
|
|
7
|
-
*
|
|
8
|
-
* @class MaxValidator
|
|
9
|
-
* @extends Validator
|
|
10
|
-
*
|
|
11
|
-
* @category Validators
|
|
12
|
-
*/
|
|
13
|
-
export declare class MaxValidator extends Validator<MaxValidatorOptions> {
|
|
14
|
-
constructor(message?: string);
|
|
15
|
-
/**
|
|
16
|
-
* @summary Validates a Model
|
|
17
|
-
*
|
|
18
|
-
* @param {string} value
|
|
19
|
-
* @param {MaxValidatorOptions} options
|
|
20
|
-
*
|
|
21
|
-
* @return {string | undefined}
|
|
22
|
-
*
|
|
23
|
-
* @override
|
|
24
|
-
*
|
|
25
|
-
* @see Validator#hasErrors
|
|
26
|
-
*/
|
|
27
|
-
hasErrors(value: number | Date | string, options: MaxValidatorOptions): string | undefined;
|
|
28
|
-
}
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
-
};
|
|
8
|
-
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.MaxValidator = void 0;
|
|
13
|
-
const Validator_1 = require("./Validator");
|
|
14
|
-
const constants_1 = require("./constants");
|
|
15
|
-
const decorators_1 = require("./decorators");
|
|
16
|
-
/**
|
|
17
|
-
* @summary Max Validator
|
|
18
|
-
*
|
|
19
|
-
* @param {string} [message] defaults to {@link DEFAULT_ERROR_MESSAGES#MAX}
|
|
20
|
-
*
|
|
21
|
-
* @class MaxValidator
|
|
22
|
-
* @extends Validator
|
|
23
|
-
*
|
|
24
|
-
* @category Validators
|
|
25
|
-
*/
|
|
26
|
-
let MaxValidator = class MaxValidator extends Validator_1.Validator {
|
|
27
|
-
constructor(message = constants_1.DEFAULT_ERROR_MESSAGES.MAX) {
|
|
28
|
-
super(message, "number", "Date", "string");
|
|
29
|
-
}
|
|
30
|
-
/**
|
|
31
|
-
* @summary Validates a Model
|
|
32
|
-
*
|
|
33
|
-
* @param {string} value
|
|
34
|
-
* @param {MaxValidatorOptions} options
|
|
35
|
-
*
|
|
36
|
-
* @return {string | undefined}
|
|
37
|
-
*
|
|
38
|
-
* @override
|
|
39
|
-
*
|
|
40
|
-
* @see Validator#hasErrors
|
|
41
|
-
*/
|
|
42
|
-
hasErrors(value, options) {
|
|
43
|
-
if (typeof value === "undefined")
|
|
44
|
-
return;
|
|
45
|
-
let { max } = options;
|
|
46
|
-
if (value instanceof Date && !(max instanceof Date)) {
|
|
47
|
-
max = new Date(max);
|
|
48
|
-
if (Number.isNaN(max.getDate()))
|
|
49
|
-
throw new Error("Invalid Max param defined");
|
|
50
|
-
}
|
|
51
|
-
return value > max
|
|
52
|
-
? this.getMessage(options.message || this.message, max)
|
|
53
|
-
: undefined;
|
|
54
|
-
}
|
|
55
|
-
};
|
|
56
|
-
exports.MaxValidator = MaxValidator;
|
|
57
|
-
exports.MaxValidator = MaxValidator = __decorate([
|
|
58
|
-
(0, decorators_1.validator)(constants_1.ValidationKeys.MAX),
|
|
59
|
-
__metadata("design:paramtypes", [String])
|
|
60
|
-
], MaxValidator);
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { Validator } from "./Validator";
|
|
2
|
-
import { MinLengthValidatorOptions } from "./types";
|
|
3
|
-
/**
|
|
4
|
-
* @summary Minimum Length Validator
|
|
5
|
-
* @description Validates strings and Arrays on their minimum length
|
|
6
|
-
*
|
|
7
|
-
* @param {string} [message] defaults to {@link DEFAULT_ERROR_MESSAGES#MIN_LENGTH}
|
|
8
|
-
*
|
|
9
|
-
* @class MinLengthValidator
|
|
10
|
-
* @extends Validator
|
|
11
|
-
*
|
|
12
|
-
* @category Validators
|
|
13
|
-
*/
|
|
14
|
-
export declare class MinLengthValidator extends Validator<MinLengthValidatorOptions> {
|
|
15
|
-
constructor(message?: string);
|
|
16
|
-
/**
|
|
17
|
-
*
|
|
18
|
-
* @param {string | Array} value
|
|
19
|
-
* @param {MinLengthValidatorOptions} options
|
|
20
|
-
*
|
|
21
|
-
* @return {string | undefined}
|
|
22
|
-
*
|
|
23
|
-
* @memberOf MinLengthValidator
|
|
24
|
-
* @override
|
|
25
|
-
*
|
|
26
|
-
* @see Validator#hasErrors
|
|
27
|
-
*/
|
|
28
|
-
hasErrors(value: string | any[], options: MinLengthValidatorOptions): string | undefined;
|
|
29
|
-
}
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
-
};
|
|
8
|
-
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.MinLengthValidator = void 0;
|
|
13
|
-
const Validator_1 = require("./Validator");
|
|
14
|
-
const constants_1 = require("./constants");
|
|
15
|
-
const decorators_1 = require("./decorators");
|
|
16
|
-
/**
|
|
17
|
-
* @summary Minimum Length Validator
|
|
18
|
-
* @description Validates strings and Arrays on their minimum length
|
|
19
|
-
*
|
|
20
|
-
* @param {string} [message] defaults to {@link DEFAULT_ERROR_MESSAGES#MIN_LENGTH}
|
|
21
|
-
*
|
|
22
|
-
* @class MinLengthValidator
|
|
23
|
-
* @extends Validator
|
|
24
|
-
*
|
|
25
|
-
* @category Validators
|
|
26
|
-
*/
|
|
27
|
-
let MinLengthValidator = class MinLengthValidator extends Validator_1.Validator {
|
|
28
|
-
constructor(message = constants_1.DEFAULT_ERROR_MESSAGES.MIN_LENGTH) {
|
|
29
|
-
super(message, String.name, Array.name);
|
|
30
|
-
}
|
|
31
|
-
/**
|
|
32
|
-
*
|
|
33
|
-
* @param {string | Array} value
|
|
34
|
-
* @param {MinLengthValidatorOptions} options
|
|
35
|
-
*
|
|
36
|
-
* @return {string | undefined}
|
|
37
|
-
*
|
|
38
|
-
* @memberOf MinLengthValidator
|
|
39
|
-
* @override
|
|
40
|
-
*
|
|
41
|
-
* @see Validator#hasErrors
|
|
42
|
-
*/
|
|
43
|
-
hasErrors(value, options) {
|
|
44
|
-
if (typeof value === "undefined")
|
|
45
|
-
return;
|
|
46
|
-
return value.length < options.minLength
|
|
47
|
-
? this.getMessage(options.message || this.message, options.minLength)
|
|
48
|
-
: undefined;
|
|
49
|
-
}
|
|
50
|
-
};
|
|
51
|
-
exports.MinLengthValidator = MinLengthValidator;
|
|
52
|
-
exports.MinLengthValidator = MinLengthValidator = __decorate([
|
|
53
|
-
(0, decorators_1.validator)(constants_1.ValidationKeys.MIN_LENGTH),
|
|
54
|
-
__metadata("design:paramtypes", [String])
|
|
55
|
-
], MinLengthValidator);
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { Validator } from "./Validator";
|
|
2
|
-
import { MinValidatorOptions } from "./types";
|
|
3
|
-
/**
|
|
4
|
-
* @summary Min Validator
|
|
5
|
-
*
|
|
6
|
-
* @param {string} [message] defaults to {@link DEFAULT_ERROR_MESSAGES#MIN}
|
|
7
|
-
*
|
|
8
|
-
* @class MinValidator
|
|
9
|
-
* @extends Validator
|
|
10
|
-
*
|
|
11
|
-
* @category Validators
|
|
12
|
-
*/
|
|
13
|
-
export declare class MinValidator extends Validator<MinValidatorOptions> {
|
|
14
|
-
constructor(message?: string);
|
|
15
|
-
/**
|
|
16
|
-
* @summary Validates Model
|
|
17
|
-
*
|
|
18
|
-
* @param {string} value
|
|
19
|
-
* @param {MaxValidatorOptions} options
|
|
20
|
-
*
|
|
21
|
-
* @return {string | undefined}
|
|
22
|
-
*
|
|
23
|
-
* @override
|
|
24
|
-
*
|
|
25
|
-
* @see Validator#hasErrors
|
|
26
|
-
*/
|
|
27
|
-
hasErrors(value: number | Date | string, options: MinValidatorOptions): string | undefined;
|
|
28
|
-
}
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
-
};
|
|
8
|
-
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.MinValidator = void 0;
|
|
13
|
-
const Validator_1 = require("./Validator");
|
|
14
|
-
const constants_1 = require("./constants");
|
|
15
|
-
const decorators_1 = require("./decorators");
|
|
16
|
-
/**
|
|
17
|
-
* @summary Min Validator
|
|
18
|
-
*
|
|
19
|
-
* @param {string} [message] defaults to {@link DEFAULT_ERROR_MESSAGES#MIN}
|
|
20
|
-
*
|
|
21
|
-
* @class MinValidator
|
|
22
|
-
* @extends Validator
|
|
23
|
-
*
|
|
24
|
-
* @category Validators
|
|
25
|
-
*/
|
|
26
|
-
let MinValidator = class MinValidator extends Validator_1.Validator {
|
|
27
|
-
constructor(message = constants_1.DEFAULT_ERROR_MESSAGES.MIN) {
|
|
28
|
-
super(message, "number", "Date", "string");
|
|
29
|
-
}
|
|
30
|
-
/**
|
|
31
|
-
* @summary Validates Model
|
|
32
|
-
*
|
|
33
|
-
* @param {string} value
|
|
34
|
-
* @param {MaxValidatorOptions} options
|
|
35
|
-
*
|
|
36
|
-
* @return {string | undefined}
|
|
37
|
-
*
|
|
38
|
-
* @override
|
|
39
|
-
*
|
|
40
|
-
* @see Validator#hasErrors
|
|
41
|
-
*/
|
|
42
|
-
hasErrors(value, options) {
|
|
43
|
-
if (typeof value === "undefined")
|
|
44
|
-
return;
|
|
45
|
-
let { min } = options;
|
|
46
|
-
if (value instanceof Date && !(min instanceof Date)) {
|
|
47
|
-
min = new Date(min);
|
|
48
|
-
if (Number.isNaN(min.getDate()))
|
|
49
|
-
throw new Error("Invalid Min param defined");
|
|
50
|
-
}
|
|
51
|
-
return value < min
|
|
52
|
-
? this.getMessage(options.message || this.message, min)
|
|
53
|
-
: undefined;
|
|
54
|
-
}
|
|
55
|
-
};
|
|
56
|
-
exports.MinValidator = MinValidator;
|
|
57
|
-
exports.MinValidator = MinValidator = __decorate([
|
|
58
|
-
(0, decorators_1.validator)(constants_1.ValidationKeys.MIN),
|
|
59
|
-
__metadata("design:paramtypes", [String])
|
|
60
|
-
], MinValidator);
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { PatternValidator } from "./PatternValidator";
|
|
2
|
-
import { PatternValidatorOptions } from "./types";
|
|
3
|
-
/**
|
|
4
|
-
* @summary Handles Password Validation
|
|
5
|
-
*
|
|
6
|
-
* @param {string} [errorMessage] defaults to {@link DEFAULT_ERROR_MESSAGES#PASSWORD}
|
|
7
|
-
*
|
|
8
|
-
* @class PasswordValidator
|
|
9
|
-
* @extends PatternValidator
|
|
10
|
-
*
|
|
11
|
-
* @category Validators
|
|
12
|
-
*/
|
|
13
|
-
export declare class PasswordValidator extends PatternValidator {
|
|
14
|
-
constructor(message?: string);
|
|
15
|
-
/**
|
|
16
|
-
* @summary Validates a model
|
|
17
|
-
*
|
|
18
|
-
* @param {string} value
|
|
19
|
-
* @param {PatternValidatorOptions} [options={}]
|
|
20
|
-
*
|
|
21
|
-
* @return {string | undefined}
|
|
22
|
-
*
|
|
23
|
-
* @override
|
|
24
|
-
*
|
|
25
|
-
* @see PatternValidator#hasErrors
|
|
26
|
-
*/
|
|
27
|
-
hasErrors(value: string, options?: PatternValidatorOptions): string | undefined;
|
|
28
|
-
}
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
-
};
|
|
8
|
-
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.PasswordValidator = void 0;
|
|
13
|
-
const PatternValidator_1 = require("./PatternValidator");
|
|
14
|
-
const constants_1 = require("./constants");
|
|
15
|
-
const decorators_1 = require("./decorators");
|
|
16
|
-
/**
|
|
17
|
-
* @summary Handles Password Validation
|
|
18
|
-
*
|
|
19
|
-
* @param {string} [errorMessage] defaults to {@link DEFAULT_ERROR_MESSAGES#PASSWORD}
|
|
20
|
-
*
|
|
21
|
-
* @class PasswordValidator
|
|
22
|
-
* @extends PatternValidator
|
|
23
|
-
*
|
|
24
|
-
* @category Validators
|
|
25
|
-
*/
|
|
26
|
-
let PasswordValidator = class PasswordValidator extends PatternValidator_1.PatternValidator {
|
|
27
|
-
constructor(message = constants_1.DEFAULT_ERROR_MESSAGES.PASSWORD) {
|
|
28
|
-
super(message);
|
|
29
|
-
}
|
|
30
|
-
/**
|
|
31
|
-
* @summary Validates a model
|
|
32
|
-
*
|
|
33
|
-
* @param {string} value
|
|
34
|
-
* @param {PatternValidatorOptions} [options={}]
|
|
35
|
-
*
|
|
36
|
-
* @return {string | undefined}
|
|
37
|
-
*
|
|
38
|
-
* @override
|
|
39
|
-
*
|
|
40
|
-
* @see PatternValidator#hasErrors
|
|
41
|
-
*/
|
|
42
|
-
hasErrors(value, options = {}) {
|
|
43
|
-
return super.hasErrors(value, {
|
|
44
|
-
...options,
|
|
45
|
-
message: options.message || this.message,
|
|
46
|
-
});
|
|
47
|
-
}
|
|
48
|
-
};
|
|
49
|
-
exports.PasswordValidator = PasswordValidator;
|
|
50
|
-
exports.PasswordValidator = PasswordValidator = __decorate([
|
|
51
|
-
(0, decorators_1.validator)(constants_1.ValidationKeys.PASSWORD),
|
|
52
|
-
__metadata("design:paramtypes", [Object])
|
|
53
|
-
], PasswordValidator);
|