@decaf-ts/decorator-validation 1.5.1 → 1.5.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.
Files changed (170) hide show
  1. package/package.json +15 -9
  2. package/dist/decorator-validation.bundle.min.js +0 -2
  3. package/dist/decorator-validation.bundle.min.js.LICENSE.txt +0 -14
  4. package/dist/esm/decorator-validation.bundle.min.esm.js +0 -2
  5. package/dist/esm/decorator-validation.bundle.min.esm.js.LICENSE.txt +0 -14
  6. package/lib/esm/index.d.ts +0 -42
  7. package/lib/esm/index.js +0 -42
  8. package/lib/esm/model/Model.d.ts +0 -138
  9. package/lib/esm/model/Model.js +0 -296
  10. package/lib/esm/model/ModelErrorDefinition.d.ts +0 -22
  11. package/lib/esm/model/ModelErrorDefinition.js +0 -52
  12. package/lib/esm/model/Registry.d.ts +0 -59
  13. package/lib/esm/model/Registry.js +0 -73
  14. package/lib/esm/model/constants.d.ts +0 -56
  15. package/lib/esm/model/constants.js +0 -69
  16. package/lib/esm/model/construction.d.ts +0 -29
  17. package/lib/esm/model/construction.js +0 -63
  18. package/lib/esm/model/decorators.d.ts +0 -25
  19. package/lib/esm/model/decorators.js +0 -62
  20. package/lib/esm/model/index.d.ts +0 -9
  21. package/lib/esm/model/index.js +0 -9
  22. package/lib/esm/model/types.d.ts +0 -79
  23. package/lib/esm/model/types.js +0 -1
  24. package/lib/esm/model/utils.d.ts +0 -11
  25. package/lib/esm/model/utils.js +0 -25
  26. package/lib/esm/model/validation.d.ts +0 -14
  27. package/lib/esm/model/validation.js +0 -135
  28. package/lib/esm/utils/constants.d.ts +0 -26
  29. package/lib/esm/utils/constants.js +0 -27
  30. package/lib/esm/utils/dates.d.ts +0 -76
  31. package/lib/esm/utils/dates.js +0 -243
  32. package/lib/esm/utils/decorators.d.ts +0 -2
  33. package/lib/esm/utils/decorators.js +0 -18
  34. package/lib/esm/utils/hashing.d.ts +0 -52
  35. package/lib/esm/utils/hashing.js +0 -99
  36. package/lib/esm/utils/index.d.ts +0 -7
  37. package/lib/esm/utils/index.js +0 -7
  38. package/lib/esm/utils/registry.d.ts +0 -68
  39. package/lib/esm/utils/registry.js +0 -1
  40. package/lib/esm/utils/serialization.d.ts +0 -79
  41. package/lib/esm/utils/serialization.js +0 -88
  42. package/lib/esm/utils/strings.d.ts +0 -25
  43. package/lib/esm/utils/strings.js +0 -31
  44. package/lib/esm/validation/Validation.d.ts +0 -51
  45. package/lib/esm/validation/Validation.js +0 -71
  46. package/lib/esm/validation/Validators/DateValidator.d.ts +0 -30
  47. package/lib/esm/validation/Validators/DateValidator.js +0 -54
  48. package/lib/esm/validation/Validators/EmailValidator.d.ts +0 -27
  49. package/lib/esm/validation/Validators/EmailValidator.js +0 -50
  50. package/lib/esm/validation/Validators/ListValidator.d.ts +0 -30
  51. package/lib/esm/validation/Validators/ListValidator.js +0 -65
  52. package/lib/esm/validation/Validators/MaxLengthValidator.d.ts +0 -31
  53. package/lib/esm/validation/Validators/MaxLengthValidator.js +0 -52
  54. package/lib/esm/validation/Validators/MaxValidator.d.ts +0 -30
  55. package/lib/esm/validation/Validators/MaxValidator.js +0 -57
  56. package/lib/esm/validation/Validators/MinLengthValidator.d.ts +0 -31
  57. package/lib/esm/validation/Validators/MinLengthValidator.js +0 -52
  58. package/lib/esm/validation/Validators/MinValidator.d.ts +0 -30
  59. package/lib/esm/validation/Validators/MinValidator.js +0 -57
  60. package/lib/esm/validation/Validators/PasswordValidator.d.ts +0 -27
  61. package/lib/esm/validation/Validators/PasswordValidator.js +0 -50
  62. package/lib/esm/validation/Validators/PatternValidator.d.ts +0 -39
  63. package/lib/esm/validation/Validators/PatternValidator.js +0 -70
  64. package/lib/esm/validation/Validators/RequiredValidator.d.ts +0 -27
  65. package/lib/esm/validation/Validators/RequiredValidator.js +0 -57
  66. package/lib/esm/validation/Validators/StepValidator.d.ts +0 -31
  67. package/lib/esm/validation/Validators/StepValidator.js +0 -52
  68. package/lib/esm/validation/Validators/TypeValidator.d.ts +0 -29
  69. package/lib/esm/validation/Validators/TypeValidator.js +0 -60
  70. package/lib/esm/validation/Validators/URLValidator.d.ts +0 -32
  71. package/lib/esm/validation/Validators/URLValidator.js +0 -46
  72. package/lib/esm/validation/Validators/Validator.d.ts +0 -43
  73. package/lib/esm/validation/Validators/Validator.js +0 -47
  74. package/lib/esm/validation/Validators/ValidatorRegistry.d.ts +0 -47
  75. package/lib/esm/validation/Validators/ValidatorRegistry.js +0 -80
  76. package/lib/esm/validation/Validators/constants.d.ts +0 -96
  77. package/lib/esm/validation/Validators/constants.js +0 -134
  78. package/lib/esm/validation/Validators/decorators.d.ts +0 -12
  79. package/lib/esm/validation/Validators/decorators.js +0 -25
  80. package/lib/esm/validation/Validators/index.d.ts +0 -52
  81. package/lib/esm/validation/Validators/index.js +0 -52
  82. package/lib/esm/validation/Validators/types.d.ts +0 -51
  83. package/lib/esm/validation/Validators/types.js +0 -1
  84. package/lib/esm/validation/decorators.d.ts +0 -178
  85. package/lib/esm/validation/decorators.js +0 -288
  86. package/lib/esm/validation/index.d.ts +0 -4
  87. package/lib/esm/validation/index.js +0 -4
  88. package/lib/esm/validation/types.d.ts +0 -46
  89. package/lib/esm/validation/types.js +0 -1
  90. package/lib/index.cjs +0 -59
  91. package/lib/index.d.ts +0 -42
  92. package/lib/model/Model.cjs +0 -300
  93. package/lib/model/Model.d.ts +0 -138
  94. package/lib/model/ModelErrorDefinition.cjs +0 -56
  95. package/lib/model/ModelErrorDefinition.d.ts +0 -22
  96. package/lib/model/Registry.cjs +0 -78
  97. package/lib/model/Registry.d.ts +0 -59
  98. package/lib/model/constants.cjs +0 -72
  99. package/lib/model/constants.d.ts +0 -56
  100. package/lib/model/construction.cjs +0 -68
  101. package/lib/model/construction.d.ts +0 -29
  102. package/lib/model/decorators.cjs +0 -67
  103. package/lib/model/decorators.d.ts +0 -25
  104. package/lib/model/index.cjs +0 -25
  105. package/lib/model/index.d.ts +0 -9
  106. package/lib/model/types.cjs +0 -2
  107. package/lib/model/types.d.ts +0 -79
  108. package/lib/model/utils.cjs +0 -29
  109. package/lib/model/utils.d.ts +0 -11
  110. package/lib/model/validation.cjs +0 -138
  111. package/lib/model/validation.d.ts +0 -14
  112. package/lib/utils/constants.cjs +0 -30
  113. package/lib/utils/constants.d.ts +0 -26
  114. package/lib/utils/dates.cjs +0 -251
  115. package/lib/utils/dates.d.ts +0 -76
  116. package/lib/utils/decorators.cjs +0 -22
  117. package/lib/utils/decorators.d.ts +0 -2
  118. package/lib/utils/hashing.cjs +0 -106
  119. package/lib/utils/hashing.d.ts +0 -52
  120. package/lib/utils/index.cjs +0 -23
  121. package/lib/utils/index.d.ts +0 -7
  122. package/lib/utils/registry.cjs +0 -2
  123. package/lib/utils/registry.d.ts +0 -68
  124. package/lib/utils/serialization.cjs +0 -93
  125. package/lib/utils/serialization.d.ts +0 -79
  126. package/lib/utils/strings.cjs +0 -35
  127. package/lib/utils/strings.d.ts +0 -25
  128. package/lib/validation/Validation.cjs +0 -75
  129. package/lib/validation/Validation.d.ts +0 -51
  130. package/lib/validation/Validators/DateValidator.cjs +0 -57
  131. package/lib/validation/Validators/DateValidator.d.ts +0 -30
  132. package/lib/validation/Validators/EmailValidator.cjs +0 -53
  133. package/lib/validation/Validators/EmailValidator.d.ts +0 -27
  134. package/lib/validation/Validators/ListValidator.cjs +0 -68
  135. package/lib/validation/Validators/ListValidator.d.ts +0 -30
  136. package/lib/validation/Validators/MaxLengthValidator.cjs +0 -55
  137. package/lib/validation/Validators/MaxLengthValidator.d.ts +0 -31
  138. package/lib/validation/Validators/MaxValidator.cjs +0 -60
  139. package/lib/validation/Validators/MaxValidator.d.ts +0 -30
  140. package/lib/validation/Validators/MinLengthValidator.cjs +0 -55
  141. package/lib/validation/Validators/MinLengthValidator.d.ts +0 -31
  142. package/lib/validation/Validators/MinValidator.cjs +0 -60
  143. package/lib/validation/Validators/MinValidator.d.ts +0 -30
  144. package/lib/validation/Validators/PasswordValidator.cjs +0 -53
  145. package/lib/validation/Validators/PasswordValidator.d.ts +0 -27
  146. package/lib/validation/Validators/PatternValidator.cjs +0 -73
  147. package/lib/validation/Validators/PatternValidator.d.ts +0 -39
  148. package/lib/validation/Validators/RequiredValidator.cjs +0 -60
  149. package/lib/validation/Validators/RequiredValidator.d.ts +0 -27
  150. package/lib/validation/Validators/StepValidator.cjs +0 -55
  151. package/lib/validation/Validators/StepValidator.d.ts +0 -31
  152. package/lib/validation/Validators/TypeValidator.cjs +0 -63
  153. package/lib/validation/Validators/TypeValidator.d.ts +0 -29
  154. package/lib/validation/Validators/URLValidator.cjs +0 -49
  155. package/lib/validation/Validators/URLValidator.d.ts +0 -32
  156. package/lib/validation/Validators/Validator.cjs +0 -51
  157. package/lib/validation/Validators/Validator.d.ts +0 -43
  158. package/lib/validation/Validators/ValidatorRegistry.cjs +0 -85
  159. package/lib/validation/Validators/ValidatorRegistry.d.ts +0 -47
  160. package/lib/validation/Validators/constants.cjs +0 -137
  161. package/lib/validation/Validators/constants.d.ts +0 -96
  162. package/lib/validation/Validators/decorators.cjs +0 -28
  163. package/lib/validation/Validators/index.cjs +0 -69
  164. package/lib/validation/Validators/types.cjs +0 -2
  165. package/lib/validation/decorators.cjs +0 -304
  166. package/lib/validation/decorators.d.ts +0 -178
  167. package/lib/validation/index.cjs +0 -20
  168. package/lib/validation/index.d.ts +0 -4
  169. package/lib/validation/types.cjs +0 -2
  170. package/lib/validation/types.d.ts +0 -46
@@ -1,31 +0,0 @@
1
- import { Validator, ValidatorOptions } from "./Validator";
2
- export interface MaxLengthValidatorOptions extends ValidatorOptions {
3
- maxLength: number;
4
- }
5
- /**
6
- * @summary Maximum Length Validator
7
- * @description Validates strings and Arrays on their maximum length
8
- *
9
- * @param {string} [message] defaults to {@link DEFAULT_ERROR_MESSAGES#MAX_LENGTH}
10
- *
11
- * @class MinLengthValidator
12
- * @extends Validator
13
- *
14
- * @category Validators
15
- */
16
- export declare class MaxLengthValidator extends Validator<MaxLengthValidatorOptions> {
17
- constructor(message?: string);
18
- /**
19
- * @summary Validates a model
20
- *
21
- * @param {string} value
22
- * @param {MaxLengthValidatorOptions} options
23
- *
24
- * @return {string | undefined}
25
- *
26
- * @override
27
- *
28
- * @see Validator#hasErrors
29
- */
30
- hasErrors(value: string | any[], options: MaxLengthValidatorOptions): string | undefined;
31
- }
@@ -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.cjs");
14
- const constants_1 = require("./constants.cjs");
15
- const decorators_1 = require("./decorators.cjs");
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,30 +0,0 @@
1
- import { Validator, ValidatorOptions } from "./Validator";
2
- export interface MaxValidatorOptions extends ValidatorOptions {
3
- max: number | Date | string;
4
- }
5
- /**
6
- * @summary Max Validator
7
- *
8
- * @param {string} [message] defaults to {@link DEFAULT_ERROR_MESSAGES#MAX}
9
- *
10
- * @class MaxValidator
11
- * @extends Validator
12
- *
13
- * @category Validators
14
- */
15
- export declare class MaxValidator extends Validator<MaxValidatorOptions> {
16
- constructor(message?: string);
17
- /**
18
- * @summary Validates a Model
19
- *
20
- * @param {string} value
21
- * @param {MaxValidatorOptions} options
22
- *
23
- * @return {string | undefined}
24
- *
25
- * @override
26
- *
27
- * @see Validator#hasErrors
28
- */
29
- hasErrors(value: number | Date | string, options: MaxValidatorOptions): string | undefined;
30
- }
@@ -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.cjs");
14
- const constants_1 = require("./constants.cjs");
15
- const decorators_1 = require("./decorators.cjs");
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,31 +0,0 @@
1
- import { Validator, ValidatorOptions } from "./Validator";
2
- export interface MinLengthValidatorOptions extends ValidatorOptions {
3
- minLength: number;
4
- }
5
- /**
6
- * @summary Minimum Length Validator
7
- * @description Validates strings and Arrays on their minimum length
8
- *
9
- * @param {string} [message] defaults to {@link DEFAULT_ERROR_MESSAGES#MIN_LENGTH}
10
- *
11
- * @class MinLengthValidator
12
- * @extends Validator
13
- *
14
- * @category Validators
15
- */
16
- export declare class MinLengthValidator extends Validator<MinLengthValidatorOptions> {
17
- constructor(message?: string);
18
- /**
19
- *
20
- * @param {string | Array} value
21
- * @param {MinLengthValidatorOptions} options
22
- *
23
- * @return {string | undefined}
24
- *
25
- * @memberOf MinLengthValidator
26
- * @override
27
- *
28
- * @see Validator#hasErrors
29
- */
30
- hasErrors(value: string | any[], options: MinLengthValidatorOptions): string | undefined;
31
- }
@@ -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.cjs");
14
- const constants_1 = require("./constants.cjs");
15
- const decorators_1 = require("./decorators.cjs");
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,30 +0,0 @@
1
- import { Validator, ValidatorOptions } from "./Validator";
2
- export interface MinValidatorOptions extends ValidatorOptions {
3
- min: number | Date | string;
4
- }
5
- /**
6
- * @summary Min Validator
7
- *
8
- * @param {string} [message] defaults to {@link DEFAULT_ERROR_MESSAGES#MIN}
9
- *
10
- * @class MinValidator
11
- * @extends Validator
12
- *
13
- * @category Validators
14
- */
15
- export declare class MinValidator extends Validator<MinValidatorOptions> {
16
- constructor(message?: string);
17
- /**
18
- * @summary Validates Model
19
- *
20
- * @param {string} value
21
- * @param {MaxValidatorOptions} options
22
- *
23
- * @return {string | undefined}
24
- *
25
- * @override
26
- *
27
- * @see Validator#hasErrors
28
- */
29
- hasErrors(value: number | Date | string, options: MinValidatorOptions): string | undefined;
30
- }
@@ -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.cjs");
14
- const constants_1 = require("./constants.cjs");
15
- const decorators_1 = require("./decorators.cjs");
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);
@@ -1,27 +0,0 @@
1
- import { PatternValidator, PatternValidatorOptions } from "./PatternValidator";
2
- /**
3
- * @summary Handles Password Validation
4
- *
5
- * @param {string} [errorMessage] defaults to {@link DEFAULT_ERROR_MESSAGES#PASSWORD}
6
- *
7
- * @class PasswordValidator
8
- * @extends PatternValidator
9
- *
10
- * @category Validators
11
- */
12
- export declare class PasswordValidator extends PatternValidator {
13
- constructor(message?: string);
14
- /**
15
- * @summary Validates a model
16
- *
17
- * @param {string} value
18
- * @param {PatternValidatorOptions} [options={}]
19
- *
20
- * @return {string | undefined}
21
- *
22
- * @override
23
- *
24
- * @see PatternValidator#hasErrors
25
- */
26
- hasErrors(value: string, options?: PatternValidatorOptions): string | undefined;
27
- }
@@ -1,73 +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.PatternValidator = exports.regexpParser = void 0;
13
- const Validator_1 = require("./Validator.cjs");
14
- const constants_1 = require("./constants.cjs");
15
- const decorators_1 = require("./decorators.cjs");
16
- exports.regexpParser = new RegExp("^/(.+)/([gimus]*)$");
17
- /**
18
- * @summary Pattern Validator
19
- *
20
- * @param {string} [key] defaults to {@link ValidationKeys#PATTERN}
21
- * @param {string} [message] defaults to {@link DEFAULT_ERROR_MESSAGES#PATTERN}
22
- *
23
- * @class PatternValidator
24
- * @extends Validator
25
- *
26
- * @category Validators
27
- */
28
- let PatternValidator = class PatternValidator extends Validator_1.Validator {
29
- constructor(message = constants_1.DEFAULT_ERROR_MESSAGES.PATTERN) {
30
- super(message, "string");
31
- }
32
- /**
33
- * @summary parses and validates a pattern
34
- *
35
- * @param {string} pattern
36
- * @private
37
- */
38
- getPattern(pattern) {
39
- if (!exports.regexpParser.test(pattern))
40
- return new RegExp(pattern);
41
- const match = pattern.match(exports.regexpParser);
42
- return new RegExp(match[1], match[2]);
43
- }
44
- /**
45
- * @summary Validates a Model
46
- *
47
- * @param {string} value
48
- * @param {PatternValidatorOptions} options
49
- *
50
- * @return {string | undefined}
51
- *
52
- * @override
53
- *
54
- * @see Validator#hasErrors
55
- */
56
- hasErrors(value, options) {
57
- if (!value)
58
- return;
59
- let { pattern } = options;
60
- if (!pattern)
61
- throw new Error("Missing Pattern");
62
- pattern = typeof pattern === "string" ? this.getPattern(pattern) : pattern;
63
- pattern.lastIndex = 0; // resets pattern position for repeat validation requests
64
- return !pattern.test(value)
65
- ? this.getMessage(options.message || this.message)
66
- : undefined;
67
- }
68
- };
69
- exports.PatternValidator = PatternValidator;
70
- exports.PatternValidator = PatternValidator = __decorate([
71
- (0, decorators_1.validator)(constants_1.ValidationKeys.PATTERN),
72
- __metadata("design:paramtypes", [String])
73
- ], PatternValidator);
@@ -1,39 +0,0 @@
1
- import { Validator, ValidatorOptions } from "./Validator";
2
- export interface PatternValidatorOptions extends ValidatorOptions {
3
- pattern?: RegExp | string;
4
- }
5
- export declare const regexpParser: RegExp;
6
- /**
7
- * @summary Pattern Validator
8
- *
9
- * @param {string} [key] defaults to {@link ValidationKeys#PATTERN}
10
- * @param {string} [message] defaults to {@link DEFAULT_ERROR_MESSAGES#PATTERN}
11
- *
12
- * @class PatternValidator
13
- * @extends Validator
14
- *
15
- * @category Validators
16
- */
17
- export declare class PatternValidator extends Validator<PatternValidatorOptions> {
18
- constructor(message?: string);
19
- /**
20
- * @summary parses and validates a pattern
21
- *
22
- * @param {string} pattern
23
- * @private
24
- */
25
- private getPattern;
26
- /**
27
- * @summary Validates a Model
28
- *
29
- * @param {string} value
30
- * @param {PatternValidatorOptions} options
31
- *
32
- * @return {string | undefined}
33
- *
34
- * @override
35
- *
36
- * @see Validator#hasErrors
37
- */
38
- hasErrors(value: string, options: PatternValidatorOptions): string | undefined;
39
- }
@@ -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.RequiredValidator = void 0;
13
- const Validator_1 = require("./Validator.cjs");
14
- const constants_1 = require("./constants.cjs");
15
- const decorators_1 = require("./decorators.cjs");
16
- /**
17
- * @summary Required Validator
18
- *
19
- * @param {string} [message] defaults to {@link DEFAULT_ERROR_MESSAGES#REQUIRED}
20
- *
21
- * @class RequiredValidator
22
- * @extends Validator
23
- *
24
- * @category Validators
25
- */
26
- let RequiredValidator = class RequiredValidator extends Validator_1.Validator {
27
- constructor(message = constants_1.DEFAULT_ERROR_MESSAGES.REQUIRED) {
28
- super(message);
29
- }
30
- /**
31
- * @summary Validates a model
32
- *
33
- * @param {string} value
34
- * @param {ValidatorOptions} [options={}]
35
- *
36
- * @return {string | undefined}
37
- *
38
- * @override
39
- *
40
- * @see Validator#hasErrors
41
- */
42
- hasErrors(value, options = {}) {
43
- switch (typeof value) {
44
- case "boolean":
45
- case "number":
46
- return typeof value === "undefined"
47
- ? this.getMessage(options.message || this.message)
48
- : undefined;
49
- default:
50
- return !value
51
- ? this.getMessage(options.message || this.message)
52
- : undefined;
53
- }
54
- }
55
- };
56
- exports.RequiredValidator = RequiredValidator;
57
- exports.RequiredValidator = RequiredValidator = __decorate([
58
- (0, decorators_1.validator)(constants_1.ValidationKeys.REQUIRED),
59
- __metadata("design:paramtypes", [String])
60
- ], RequiredValidator);
@@ -1,27 +0,0 @@
1
- import { Validator, ValidatorOptions } from "./Validator";
2
- /**
3
- * @summary Required Validator
4
- *
5
- * @param {string} [message] defaults to {@link DEFAULT_ERROR_MESSAGES#REQUIRED}
6
- *
7
- * @class RequiredValidator
8
- * @extends Validator
9
- *
10
- * @category Validators
11
- */
12
- export declare class RequiredValidator extends Validator {
13
- constructor(message?: string);
14
- /**
15
- * @summary Validates a model
16
- *
17
- * @param {string} value
18
- * @param {ValidatorOptions} [options={}]
19
- *
20
- * @return {string | undefined}
21
- *
22
- * @override
23
- *
24
- * @see Validator#hasErrors
25
- */
26
- hasErrors(value: any, options?: ValidatorOptions): string | undefined;
27
- }
@@ -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.StepValidator = void 0;
13
- const Validator_1 = require("./Validator.cjs");
14
- const constants_1 = require("./constants.cjs");
15
- const decorators_1 = require("./decorators.cjs");
16
- /**
17
- * @summary Step Validator
18
- *
19
- * @param {string} [message] defaults to {@link DEFAULT_ERROR_MESSAGES#STEP}
20
- *
21
- * @class StepValidator
22
- * @extends Validator
23
- *
24
- * @category Validators
25
- */
26
- let StepValidator = class StepValidator extends Validator_1.Validator {
27
- constructor(message = constants_1.DEFAULT_ERROR_MESSAGES.STEP) {
28
- super(message, "number", "string");
29
- }
30
- /**
31
- * @summary Validates a model
32
- *
33
- * @param {string} value
34
- * @param {number} step
35
- * @param {StepValidatorOptions} 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 Number(value) % Number(options.step) !== 0
47
- ? this.getMessage(options.message || this.message, options.step)
48
- : undefined;
49
- }
50
- };
51
- exports.StepValidator = StepValidator;
52
- exports.StepValidator = StepValidator = __decorate([
53
- (0, decorators_1.validator)(constants_1.ValidationKeys.STEP),
54
- __metadata("design:paramtypes", [String])
55
- ], StepValidator);
@@ -1,31 +0,0 @@
1
- import { Validator, ValidatorOptions } from "./Validator";
2
- export interface StepValidatorOptions extends ValidatorOptions {
3
- step: number | string;
4
- }
5
- /**
6
- * @summary Step Validator
7
- *
8
- * @param {string} [message] defaults to {@link DEFAULT_ERROR_MESSAGES#STEP}
9
- *
10
- * @class StepValidator
11
- * @extends Validator
12
- *
13
- * @category Validators
14
- */
15
- export declare class StepValidator extends Validator<StepValidatorOptions> {
16
- constructor(message?: string);
17
- /**
18
- * @summary Validates a model
19
- *
20
- * @param {string} value
21
- * @param {number} step
22
- * @param {StepValidatorOptions} options
23
- *
24
- * @return {string | undefined}
25
- *
26
- * @override
27
- *
28
- * @see Validator#hasErrors
29
- */
30
- hasErrors(value: number | string, options: StepValidatorOptions): string | undefined;
31
- }