@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,51 +0,0 @@
|
|
|
1
|
-
import { Validator } from "./Validators/Validator";
|
|
2
|
-
import { IValidatorRegistry, ValidatorDefinition } from "./Validators/types";
|
|
3
|
-
/**
|
|
4
|
-
* @summary Static class acting as a namespace for the Validation
|
|
5
|
-
*
|
|
6
|
-
* @class Validation
|
|
7
|
-
* @static
|
|
8
|
-
*
|
|
9
|
-
* @category Validation
|
|
10
|
-
*/
|
|
11
|
-
export declare class Validation {
|
|
12
|
-
private static actingValidatorRegistry?;
|
|
13
|
-
private constructor();
|
|
14
|
-
/**
|
|
15
|
-
* @summary Defines the acting ValidatorRegistry
|
|
16
|
-
*
|
|
17
|
-
* @param {IValidatorRegistry} validatorRegistry the new implementation of the validator Registry
|
|
18
|
-
* @param {function(Validator): Validator} [migrationHandler] the method to map the validator if required;
|
|
19
|
-
*/
|
|
20
|
-
static setRegistry(validatorRegistry: IValidatorRegistry<Validator>, migrationHandler?: (validator: Validator) => Validator): void;
|
|
21
|
-
/**
|
|
22
|
-
* @summary Returns the current ValidatorRegistry
|
|
23
|
-
*
|
|
24
|
-
* @return IValidatorRegistry, defaults to {@link ValidatorRegistry}
|
|
25
|
-
*/
|
|
26
|
-
private static getRegistry;
|
|
27
|
-
/**
|
|
28
|
-
* @summary Retrieves a validator
|
|
29
|
-
*
|
|
30
|
-
* @param {string} validatorKey one of the {@link ValidationKeys}
|
|
31
|
-
* @return {Validator | undefined} the registered Validator or undefined if there is nono matching the provided key
|
|
32
|
-
*/
|
|
33
|
-
static get<T extends Validator>(validatorKey: string): T | undefined;
|
|
34
|
-
/**
|
|
35
|
-
* @summary Registers the provided validators onto the registry
|
|
36
|
-
*
|
|
37
|
-
* @param {T[] | ValidatorDefinition[]} validator
|
|
38
|
-
*/
|
|
39
|
-
static register<T extends Validator>(...validator: (ValidatorDefinition | T)[]): void;
|
|
40
|
-
/**
|
|
41
|
-
* @summary Builds the key to store as Metadata under Reflections
|
|
42
|
-
* @description concatenates {@link ValidationKeys#REFLECT} with the provided key
|
|
43
|
-
*
|
|
44
|
-
* @param {string} key
|
|
45
|
-
*/
|
|
46
|
-
static key(key: string): string;
|
|
47
|
-
/**
|
|
48
|
-
* @summary Returns all registered validation keys
|
|
49
|
-
*/
|
|
50
|
-
static keys(): string[];
|
|
51
|
-
}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { Validator } from "./Validator";
|
|
2
|
-
import { DateValidatorOptions } from "./types";
|
|
3
|
-
/**
|
|
4
|
-
* @summary Date Validator
|
|
5
|
-
*
|
|
6
|
-
* @param {string} [message] defaults to {@link DEFAULT_ERROR_MESSAGES#DATE}
|
|
7
|
-
*
|
|
8
|
-
* @class DateValidator
|
|
9
|
-
* @extends Validator
|
|
10
|
-
*
|
|
11
|
-
* @category Validators
|
|
12
|
-
*/
|
|
13
|
-
export declare class DateValidator extends Validator<DateValidatorOptions> {
|
|
14
|
-
constructor(message?: string);
|
|
15
|
-
/**
|
|
16
|
-
* @summary Validates a model
|
|
17
|
-
*
|
|
18
|
-
* @param {Date | string} value
|
|
19
|
-
* @param {DateValidatorOptions} [options]
|
|
20
|
-
*
|
|
21
|
-
* @return {string | undefined}
|
|
22
|
-
*
|
|
23
|
-
* @override
|
|
24
|
-
*
|
|
25
|
-
* @see Validator#hasErrors
|
|
26
|
-
*/
|
|
27
|
-
hasErrors(value: Date | string, options?: DateValidatorOptions): string | undefined;
|
|
28
|
-
}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { PatternValidator } from "./PatternValidator";
|
|
2
|
-
import { PatternValidatorOptions } from "./types";
|
|
3
|
-
/**
|
|
4
|
-
* @summary Email Validator
|
|
5
|
-
*
|
|
6
|
-
* @param {string} [message] defaults to {@link DEFAULT_ERROR_MESSAGES#EMAIL}
|
|
7
|
-
*
|
|
8
|
-
* @class EmailValidator
|
|
9
|
-
* @extends PatternValidator
|
|
10
|
-
*
|
|
11
|
-
* @category Validators
|
|
12
|
-
*/
|
|
13
|
-
export declare class EmailValidator 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 Validator#hasErrors
|
|
26
|
-
*/
|
|
27
|
-
hasErrors(value: string, options?: PatternValidatorOptions): string | undefined;
|
|
28
|
-
}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { Validator } from "./Validator";
|
|
2
|
-
import { ListValidatorOptions } from "./types";
|
|
3
|
-
/**
|
|
4
|
-
* @summary List Validator
|
|
5
|
-
*
|
|
6
|
-
* @param {string} [message] defaults to {@link DEFAULT_ERROR_MESSAGES#LIST}
|
|
7
|
-
*
|
|
8
|
-
* @class ListValidator
|
|
9
|
-
* @extends Validator
|
|
10
|
-
*
|
|
11
|
-
* @category Validators
|
|
12
|
-
*/
|
|
13
|
-
export declare class ListValidator extends Validator<ListValidatorOptions> {
|
|
14
|
-
constructor(message?: string);
|
|
15
|
-
/**
|
|
16
|
-
* @summary Validates a model
|
|
17
|
-
*
|
|
18
|
-
* @param {any[] | Set<any>} value
|
|
19
|
-
* @param {ListValidatorOptions} options
|
|
20
|
-
*
|
|
21
|
-
* @return {string | undefined}
|
|
22
|
-
*
|
|
23
|
-
* @override
|
|
24
|
-
*
|
|
25
|
-
* @see Validator#hasErrors
|
|
26
|
-
*/
|
|
27
|
-
hasErrors(value: any[] | Set<any>, options: ListValidatorOptions): string | undefined;
|
|
28
|
-
}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { Validator } from "./Validator";
|
|
2
|
-
import { MaxLengthValidatorOptions } from "./types";
|
|
3
|
-
/**
|
|
4
|
-
* @summary Maximum Length Validator
|
|
5
|
-
* @description Validates strings and Arrays on their maximum length
|
|
6
|
-
*
|
|
7
|
-
* @param {string} [message] defaults to {@link DEFAULT_ERROR_MESSAGES#MAX_LENGTH}
|
|
8
|
-
*
|
|
9
|
-
* @class MinLengthValidator
|
|
10
|
-
* @extends Validator
|
|
11
|
-
*
|
|
12
|
-
* @category Validators
|
|
13
|
-
*/
|
|
14
|
-
export declare class MaxLengthValidator extends Validator<MaxLengthValidatorOptions> {
|
|
15
|
-
constructor(message?: string);
|
|
16
|
-
/**
|
|
17
|
-
* @summary Validates a model
|
|
18
|
-
*
|
|
19
|
-
* @param {string} value
|
|
20
|
-
* @param {MaxLengthValidatorOptions} options
|
|
21
|
-
*
|
|
22
|
-
* @return {string | undefined}
|
|
23
|
-
*
|
|
24
|
-
* @override
|
|
25
|
-
*
|
|
26
|
-
* @see Validator#hasErrors
|
|
27
|
-
*/
|
|
28
|
-
hasErrors(value: string | any[], options: MaxLengthValidatorOptions): string | undefined;
|
|
29
|
-
}
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { Validator } from "./Validator";
|
|
2
|
-
import { PatternValidatorOptions } from "./types";
|
|
3
|
-
export declare const regexpParser: RegExp;
|
|
4
|
-
/**
|
|
5
|
-
* @summary Pattern Validator
|
|
6
|
-
*
|
|
7
|
-
* @param {string} [key] defaults to {@link ValidationKeys#PATTERN}
|
|
8
|
-
* @param {string} [message] defaults to {@link DEFAULT_ERROR_MESSAGES#PATTERN}
|
|
9
|
-
*
|
|
10
|
-
* @class PatternValidator
|
|
11
|
-
* @extends Validator
|
|
12
|
-
*
|
|
13
|
-
* @category Validators
|
|
14
|
-
*/
|
|
15
|
-
export declare class PatternValidator extends Validator<PatternValidatorOptions> {
|
|
16
|
-
constructor(message?: string);
|
|
17
|
-
/**
|
|
18
|
-
* @summary parses and validates a pattern
|
|
19
|
-
*
|
|
20
|
-
* @param {string} pattern
|
|
21
|
-
* @private
|
|
22
|
-
*/
|
|
23
|
-
private getPattern;
|
|
24
|
-
/**
|
|
25
|
-
* @summary Validates a Model
|
|
26
|
-
*
|
|
27
|
-
* @param {string} value
|
|
28
|
-
* @param {PatternValidatorOptions} options
|
|
29
|
-
*
|
|
30
|
-
* @return {string | undefined}
|
|
31
|
-
*
|
|
32
|
-
* @override
|
|
33
|
-
*
|
|
34
|
-
* @see Validator#hasErrors
|
|
35
|
-
*/
|
|
36
|
-
hasErrors(value: string, options: PatternValidatorOptions): string | undefined;
|
|
37
|
-
}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { Validator } from "./Validator";
|
|
2
|
-
import { TypeValidatorOptions } from "./types";
|
|
3
|
-
/**
|
|
4
|
-
* @summary Required Validator
|
|
5
|
-
*
|
|
6
|
-
* @class RequiredValidator
|
|
7
|
-
* @extends Validator
|
|
8
|
-
*
|
|
9
|
-
* @category Validators
|
|
10
|
-
*/
|
|
11
|
-
export declare class TypeValidator extends Validator<TypeValidatorOptions> {
|
|
12
|
-
constructor(message?: string);
|
|
13
|
-
/**
|
|
14
|
-
* @summary Validates a model
|
|
15
|
-
* @param {string} value
|
|
16
|
-
* @param {TypeValidatorOptions} options
|
|
17
|
-
*
|
|
18
|
-
* @return {string | undefined}
|
|
19
|
-
*
|
|
20
|
-
* @override
|
|
21
|
-
*
|
|
22
|
-
* @see Validator#hasErrors
|
|
23
|
-
*/
|
|
24
|
-
hasErrors(value: any, options: TypeValidatorOptions): string | undefined;
|
|
25
|
-
}
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import { DateValidator } from "./DateValidator";
|
|
2
|
-
import { TypeValidator } from "./TypeValidator";
|
|
3
|
-
import { PasswordValidator } from "./PasswordValidator";
|
|
4
|
-
import { StepValidator } from "./StepValidator";
|
|
5
|
-
import { URLValidator } from "./URLValidator";
|
|
6
|
-
import { PatternValidator } from "./PatternValidator";
|
|
7
|
-
import { MinValidator } from "./MinValidator";
|
|
8
|
-
import { MinLengthValidator } from "./MinLengthValidator";
|
|
9
|
-
import { MaxValidator } from "./MaxValidator";
|
|
10
|
-
import { MaxLengthValidator } from "./MaxLengthValidator";
|
|
11
|
-
import { RequiredValidator } from "./RequiredValidator";
|
|
12
|
-
import { EmailValidator } from "./EmailValidator";
|
|
13
|
-
import { ListValidator } from "./ListValidator";
|
|
14
|
-
export * from "./constants";
|
|
15
|
-
export * from "./DateValidator";
|
|
16
|
-
export * from "./decorators";
|
|
17
|
-
export * from "./EmailValidator";
|
|
18
|
-
export * from "./ListValidator";
|
|
19
|
-
export * from "./MaxLengthValidator";
|
|
20
|
-
export * from "./MaxValidator";
|
|
21
|
-
export * from "./MinLengthValidator";
|
|
22
|
-
export * from "./MinValidator";
|
|
23
|
-
export * from "./PasswordValidator";
|
|
24
|
-
export * from "./PatternValidator";
|
|
25
|
-
export * from "./RequiredValidator";
|
|
26
|
-
export * from "./StepValidator";
|
|
27
|
-
export * from "./types";
|
|
28
|
-
export * from "./TypeValidator";
|
|
29
|
-
export * from "./URLValidator";
|
|
30
|
-
export * from "./Validator";
|
|
31
|
-
export * from "./ValidatorRegistry";
|
|
32
|
-
/**
|
|
33
|
-
* @summary constant holding all {@link Validator}s
|
|
34
|
-
* @constant Validators
|
|
35
|
-
* @memberOf module:decorator-validation.Validation.Validators
|
|
36
|
-
* @category Validation
|
|
37
|
-
*/
|
|
38
|
-
export declare const Validators: {
|
|
39
|
-
DateValidator: typeof DateValidator;
|
|
40
|
-
EmailValidator: typeof EmailValidator;
|
|
41
|
-
ListValidator: typeof ListValidator;
|
|
42
|
-
MaxLengthValidator: typeof MaxLengthValidator;
|
|
43
|
-
MaxValidator: typeof MaxValidator;
|
|
44
|
-
MinLengthValidator: typeof MinLengthValidator;
|
|
45
|
-
MinValidator: typeof MinValidator;
|
|
46
|
-
PasswordValidator: typeof PasswordValidator;
|
|
47
|
-
PatternValidator: typeof PatternValidator;
|
|
48
|
-
RequiredValidator: typeof RequiredValidator;
|
|
49
|
-
StepValidator: typeof StepValidator;
|
|
50
|
-
TypeValidator: typeof TypeValidator;
|
|
51
|
-
URLValidator: typeof URLValidator;
|
|
52
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import { DecoratorMetadata } from "@decaf-ts/reflection";
|
|
2
|
-
/**
|
|
3
|
-
* @summary Type for validation decorator metadata
|
|
4
|
-
* @memberOf module:decorator-validation.Reflection
|
|
5
|
-
* @category Reflection
|
|
6
|
-
*/
|
|
7
|
-
export type ValidationMetadata = {
|
|
8
|
-
[indexer: string]: any;
|
|
9
|
-
args?: any[];
|
|
10
|
-
message: string;
|
|
11
|
-
types?: string[];
|
|
12
|
-
};
|
|
13
|
-
/**
|
|
14
|
-
* @summary Type for a validator property decorator definition
|
|
15
|
-
* @memberOf module:decorator-validation.Validation
|
|
16
|
-
* @category Validation
|
|
17
|
-
*/
|
|
18
|
-
export type ValidationPropertyDecoratorDefinition = {
|
|
19
|
-
prop: string | symbol;
|
|
20
|
-
decorators: ValidationDecoratorDefinition[];
|
|
21
|
-
};
|
|
22
|
-
/**
|
|
23
|
-
* @summary Type for a validator decorator definition
|
|
24
|
-
* @memberOf module:decorator-validation.Validation
|
|
25
|
-
* @category Validation
|
|
26
|
-
*/
|
|
27
|
-
export type ValidationDecoratorDefinition = DecoratorMetadata & {
|
|
28
|
-
props: ValidationElementDefinition;
|
|
29
|
-
};
|
|
30
|
-
/**
|
|
31
|
-
* @summary Type for a validator element metadata
|
|
32
|
-
* @memberOf module:decorator-validation.Validation
|
|
33
|
-
* @category Validation
|
|
34
|
-
*/
|
|
35
|
-
export type ValidationElementDefinition = {
|
|
36
|
-
[indexer: string]: any;
|
|
37
|
-
value?: string | number;
|
|
38
|
-
message: string;
|
|
39
|
-
types?: string[];
|
|
40
|
-
};
|
|
41
|
-
/**
|
|
42
|
-
* @summary Type for a model errors
|
|
43
|
-
* @memberOf module:decorator-validation.Validation
|
|
44
|
-
* @category Validation
|
|
45
|
-
*/
|
|
46
|
-
export type ModelErrors = Record<string, Record<string, string | undefined>>;
|
package/lib/index.d.ts
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @module decorator-validation
|
|
3
|
-
*/
|
|
4
|
-
/**
|
|
5
|
-
* @summary Model definition functionality
|
|
6
|
-
* @description defines the base class and related functionality
|
|
7
|
-
*
|
|
8
|
-
* @namespace Model
|
|
9
|
-
* @memberOf module:decorator-validation
|
|
10
|
-
*/
|
|
11
|
-
/**
|
|
12
|
-
* @summary Holds all the supported decorators
|
|
13
|
-
* @namespace Decorators
|
|
14
|
-
* @memberOf module:decorator-validation
|
|
15
|
-
*/
|
|
16
|
-
/**
|
|
17
|
-
* @summary Validation related functionality
|
|
18
|
-
* @description Defines the Model validation apis and base classes for validators
|
|
19
|
-
*
|
|
20
|
-
* @namespace Validation
|
|
21
|
-
* @memberOf module:decorator-validation
|
|
22
|
-
*/
|
|
23
|
-
/**
|
|
24
|
-
* @namespace Dates
|
|
25
|
-
* @memberOf module:decorator-validation
|
|
26
|
-
*/
|
|
27
|
-
/**
|
|
28
|
-
* @namespace Hashing
|
|
29
|
-
* @memberOf module:decorator-validation
|
|
30
|
-
*/
|
|
31
|
-
/**
|
|
32
|
-
* @namespace Serialization
|
|
33
|
-
* @memberOf module:decorator-validation
|
|
34
|
-
*/
|
|
35
|
-
/**
|
|
36
|
-
* @namespace Format
|
|
37
|
-
* @memberOf module:decorator-validation
|
|
38
|
-
*/
|
|
39
|
-
export * from "./utils";
|
|
40
|
-
export * from "./validation";
|
|
41
|
-
export * from "./model";
|
|
42
|
-
export declare const VERSION = "1.5.7";
|
package/lib/index.js
DELETED
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* @module decorator-validation
|
|
4
|
-
*/
|
|
5
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
6
|
-
if (k2 === undefined) k2 = k;
|
|
7
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
8
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
9
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
10
|
-
}
|
|
11
|
-
Object.defineProperty(o, k2, desc);
|
|
12
|
-
}) : (function(o, m, k, k2) {
|
|
13
|
-
if (k2 === undefined) k2 = k;
|
|
14
|
-
o[k2] = m[k];
|
|
15
|
-
}));
|
|
16
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
17
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
18
|
-
};
|
|
19
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
-
exports.VERSION = void 0;
|
|
21
|
-
/**
|
|
22
|
-
* @summary Model definition functionality
|
|
23
|
-
* @description defines the base class and related functionality
|
|
24
|
-
*
|
|
25
|
-
* @namespace Model
|
|
26
|
-
* @memberOf module:decorator-validation
|
|
27
|
-
*/
|
|
28
|
-
/**
|
|
29
|
-
* @summary Holds all the supported decorators
|
|
30
|
-
* @namespace Decorators
|
|
31
|
-
* @memberOf module:decorator-validation
|
|
32
|
-
*/
|
|
33
|
-
/**
|
|
34
|
-
* @summary Validation related functionality
|
|
35
|
-
* @description Defines the Model validation apis and base classes for validators
|
|
36
|
-
*
|
|
37
|
-
* @namespace Validation
|
|
38
|
-
* @memberOf module:decorator-validation
|
|
39
|
-
*/
|
|
40
|
-
/**
|
|
41
|
-
* @namespace Dates
|
|
42
|
-
* @memberOf module:decorator-validation
|
|
43
|
-
*/
|
|
44
|
-
/**
|
|
45
|
-
* @namespace Hashing
|
|
46
|
-
* @memberOf module:decorator-validation
|
|
47
|
-
*/
|
|
48
|
-
/**
|
|
49
|
-
* @namespace Serialization
|
|
50
|
-
* @memberOf module:decorator-validation
|
|
51
|
-
*/
|
|
52
|
-
/**
|
|
53
|
-
* @namespace Format
|
|
54
|
-
* @memberOf module:decorator-validation
|
|
55
|
-
*/
|
|
56
|
-
__exportStar(require("./utils"), exports);
|
|
57
|
-
__exportStar(require("./validation"), exports);
|
|
58
|
-
__exportStar(require("./model"), exports);
|
|
59
|
-
exports.VERSION = "1.5.7";
|
package/lib/model/Model.d.ts
DELETED
|
@@ -1,203 +0,0 @@
|
|
|
1
|
-
import { BuilderRegistry } from "../utils/registry";
|
|
2
|
-
import { ModelErrorDefinition } from "./ModelErrorDefinition";
|
|
3
|
-
import { Comparable, Constructor, Hashable, ModelArg, ModelBuilderFunction, ModelConstructor, Serializable, Validatable } from "./types";
|
|
4
|
-
/**
|
|
5
|
-
* @summary For Serialization/deserialization purposes.
|
|
6
|
-
* @description Reads the {@link ModelKeys.ANCHOR} property of a {@link Model} to discover the class to instantiate
|
|
7
|
-
*
|
|
8
|
-
* @function isModel
|
|
9
|
-
* @memberOf module:decorator-validation.Validation
|
|
10
|
-
* @category Validation
|
|
11
|
-
*/
|
|
12
|
-
export declare function isModel(target: Record<string, any>): boolean;
|
|
13
|
-
/**
|
|
14
|
-
* @summary ModelRegistry Interface
|
|
15
|
-
*
|
|
16
|
-
* @interface ModelRegistry
|
|
17
|
-
* @extends BuilderRegistry<Model>
|
|
18
|
-
*
|
|
19
|
-
* @category Model
|
|
20
|
-
*/
|
|
21
|
-
export type ModelRegistry<T extends Model> = BuilderRegistry<T>;
|
|
22
|
-
/**
|
|
23
|
-
* @summary Util class to enable serialization and correct rebuilding
|
|
24
|
-
*
|
|
25
|
-
* @param {string} anchorKey defaults to {@link ModelKeys.ANCHOR}. The property name where the registered class name is stored;
|
|
26
|
-
* @param {function(Record<string, any>): boolean} [testFunction] method to test if the provided object is a Model Object. defaults to {@link isModel}
|
|
27
|
-
*
|
|
28
|
-
* @class ModelRegistryManager
|
|
29
|
-
* @implements ModelRegistry
|
|
30
|
-
*
|
|
31
|
-
* @category Model
|
|
32
|
-
*/
|
|
33
|
-
export declare class ModelRegistryManager<T extends Model> implements ModelRegistry<T> {
|
|
34
|
-
private cache;
|
|
35
|
-
private readonly testFunction;
|
|
36
|
-
constructor(testFunction?: (obj: Record<string, any>) => boolean);
|
|
37
|
-
/**
|
|
38
|
-
* @summary register new Models
|
|
39
|
-
* @param {any} constructor
|
|
40
|
-
* @param {string} [name] when not defined, the name of the constructor will be used
|
|
41
|
-
*/
|
|
42
|
-
register(constructor: ModelConstructor<T>, name?: string): void;
|
|
43
|
-
/**
|
|
44
|
-
* @summary Gets a registered Model {@link ModelConstructor}
|
|
45
|
-
* @param {string} name
|
|
46
|
-
*/
|
|
47
|
-
get(name: string): ModelConstructor<T> | undefined;
|
|
48
|
-
/**
|
|
49
|
-
* @param {Record<string, any>} obj
|
|
50
|
-
* @param {string} [clazz] when provided, it will attempt to find the matching constructor
|
|
51
|
-
*
|
|
52
|
-
* @throws Error If clazz is not found, or obj is not a {@link Model} meaning it has no {@link ModelKeys.ANCHOR} property
|
|
53
|
-
*/
|
|
54
|
-
build(obj?: Record<string, any>, clazz?: string): T;
|
|
55
|
-
}
|
|
56
|
-
/**
|
|
57
|
-
* @summary Bulk Registers Models
|
|
58
|
-
* @description Useful when using bundlers that might not evaluate all the code at once
|
|
59
|
-
*
|
|
60
|
-
* @param {Array<Constructor<T>> | Array<{name: string, constructor: Constructor<T>}>} [models]
|
|
61
|
-
*
|
|
62
|
-
* @memberOf module:decorator-validation.Model
|
|
63
|
-
* @category Model
|
|
64
|
-
*/
|
|
65
|
-
export declare function bulkModelRegister<T extends Model>(...models: (Constructor<T> | {
|
|
66
|
-
name: string;
|
|
67
|
-
constructor: Constructor<T>;
|
|
68
|
-
})[]): void;
|
|
69
|
-
/**
|
|
70
|
-
* @summary Abstract class representing a Validatable Model object
|
|
71
|
-
* @description Meant to be used as a base class for all Model classes
|
|
72
|
-
*
|
|
73
|
-
* Model objects must:
|
|
74
|
-
* - Have all their required properties marked with '!';
|
|
75
|
-
* - Have all their optional properties marked as '?':
|
|
76
|
-
*
|
|
77
|
-
* @param {Model | {}} model base object from which to populate properties from
|
|
78
|
-
*
|
|
79
|
-
* @class Model
|
|
80
|
-
* @abstract
|
|
81
|
-
* @implements Validatable
|
|
82
|
-
* @implements Serializable
|
|
83
|
-
*
|
|
84
|
-
* @example
|
|
85
|
-
* class ClassName {
|
|
86
|
-
* @required()
|
|
87
|
-
* requiredPropertyName!: PropertyType;
|
|
88
|
-
*
|
|
89
|
-
* optionalPropertyName?: PropertyType;
|
|
90
|
-
* }
|
|
91
|
-
*/
|
|
92
|
-
export declare abstract class Model implements Validatable, Serializable, Hashable, Comparable<Model> {
|
|
93
|
-
protected constructor(arg?: ModelArg<Model>);
|
|
94
|
-
/**
|
|
95
|
-
* @summary Validates the object according to its decorated properties
|
|
96
|
-
*
|
|
97
|
-
* @param {any[]} [exceptions] properties in the object to be ignored for the validation. Marked as 'any' to allow for extension but expects strings
|
|
98
|
-
*/
|
|
99
|
-
hasErrors(...exceptions: any[]): ModelErrorDefinition | undefined;
|
|
100
|
-
/**
|
|
101
|
-
* @summary Compare object equality recursively
|
|
102
|
-
* @param {any} obj object to compare to
|
|
103
|
-
* @param {string} [exceptions] property names to be excluded from the comparison
|
|
104
|
-
*/
|
|
105
|
-
equals(obj: any, ...exceptions: string[]): boolean;
|
|
106
|
-
/**
|
|
107
|
-
* @summary Returns the serialized model according to the currently defined {@link Serializer}
|
|
108
|
-
*/
|
|
109
|
-
serialize(): string;
|
|
110
|
-
/**
|
|
111
|
-
* @summary Override the implementation for js's 'toString()' which sucks...
|
|
112
|
-
* @override
|
|
113
|
-
*/
|
|
114
|
-
toString(): string;
|
|
115
|
-
/**
|
|
116
|
-
* @summary Defines a default implementation for object hash. Relies on a very basic implementation based on Java's string hash;
|
|
117
|
-
*/
|
|
118
|
-
hash(): string;
|
|
119
|
-
/**
|
|
120
|
-
* @summary Deserializes a Model
|
|
121
|
-
* @param {string} str
|
|
122
|
-
*
|
|
123
|
-
* @throws {Error} If it fails to parse the string, or if it fails to build the model
|
|
124
|
-
*/
|
|
125
|
-
static deserialize(str: string): any;
|
|
126
|
-
/**
|
|
127
|
-
* @summary Repopulates the Object properties with the ones from the new object
|
|
128
|
-
* @description Iterates all common properties of obj (if existing) and self, and copies them onto self
|
|
129
|
-
*
|
|
130
|
-
* @param {T} self
|
|
131
|
-
* @param {T | Record<string, any>} [obj]
|
|
132
|
-
*
|
|
133
|
-
*/
|
|
134
|
-
static fromObject<T extends Model>(self: T, obj?: T | Record<string, any>): T;
|
|
135
|
-
/**
|
|
136
|
-
* @summary Repopulates the instance with the ones from the new Model Object
|
|
137
|
-
* @description Iterates all common properties of obj (if existing) and self, and copies them onto self.
|
|
138
|
-
* Is aware of nested Model Objects and rebuilds them also.
|
|
139
|
-
* When List properties are decorated with {@link list}, they list items will also be rebuilt
|
|
140
|
-
*
|
|
141
|
-
* @param {T} self
|
|
142
|
-
* @param {T | Record<string, any>} [obj]
|
|
143
|
-
*
|
|
144
|
-
*/
|
|
145
|
-
static fromModel<T extends Model>(self: T, obj?: T | Record<string, any>): T;
|
|
146
|
-
/**
|
|
147
|
-
* @summary Sets the Global {@link ModelBuilderFunction}
|
|
148
|
-
* @param {ModelBuilderFunction} [builder]
|
|
149
|
-
*/
|
|
150
|
-
static setBuilder(builder?: ModelBuilderFunction): void;
|
|
151
|
-
/**
|
|
152
|
-
* @summary Retrieves the current global {@link ModelBuilderFunction}
|
|
153
|
-
*/
|
|
154
|
-
static getBuilder(): ModelBuilderFunction | undefined;
|
|
155
|
-
/**
|
|
156
|
-
* Returns the current {@link ModelRegistryManager}
|
|
157
|
-
*
|
|
158
|
-
* @return ModelRegistry, defaults to {@link ModelRegistryManager}
|
|
159
|
-
*/
|
|
160
|
-
private static getRegistry;
|
|
161
|
-
/**
|
|
162
|
-
* Returns the current actingModelRegistry
|
|
163
|
-
*
|
|
164
|
-
* @param {BuilderRegistry} modelRegistry the new implementation of Registry
|
|
165
|
-
*/
|
|
166
|
-
static setRegistry(modelRegistry: BuilderRegistry<any>): void;
|
|
167
|
-
/**
|
|
168
|
-
* @summary register new Models
|
|
169
|
-
* @param {any} constructor
|
|
170
|
-
* @param {string} [name] when not defined, the name of the constructor will be used
|
|
171
|
-
*
|
|
172
|
-
* @see ModelRegistry
|
|
173
|
-
*/
|
|
174
|
-
static register<T extends Model>(constructor: ModelConstructor<T>, name?: string): void;
|
|
175
|
-
/**
|
|
176
|
-
* @summary Gets a registered Model {@link ModelConstructor}
|
|
177
|
-
* @param {string} name
|
|
178
|
-
*
|
|
179
|
-
* @see ModelRegistry
|
|
180
|
-
*/
|
|
181
|
-
static get<T extends Model>(name: string): ModelConstructor<T> | undefined;
|
|
182
|
-
/**
|
|
183
|
-
* @param {Record<string, any>} obj
|
|
184
|
-
* @param {string} [clazz] when provided, it will attempt to find the matching constructor
|
|
185
|
-
*
|
|
186
|
-
* @throws Error If clazz is not found, or obj is not a {@link Model} meaning it has no {@link ModelKeys.ANCHOR} property
|
|
187
|
-
*
|
|
188
|
-
* @see ModelRegistry
|
|
189
|
-
*/
|
|
190
|
-
static build<T extends Model>(obj?: Record<string, any>, clazz?: string): T;
|
|
191
|
-
static getMetadata<V extends Model>(model: V): any;
|
|
192
|
-
static getAttributes<V extends Model>(model: Constructor<V> | V): string[];
|
|
193
|
-
static equals<V extends Model>(obj1: V, obj2: V, ...exceptions: any[]): boolean;
|
|
194
|
-
static hasErrors<V extends Model>(model: V, ...propsToIgnore: string[]): ModelErrorDefinition | undefined;
|
|
195
|
-
static serialize<V extends Model>(model: V): any;
|
|
196
|
-
static hash<V extends Model>(model: V): any;
|
|
197
|
-
/**
|
|
198
|
-
* @summary Builds the key to store as Metadata under Reflections
|
|
199
|
-
* @description concatenates {@link ModelKeys#REFLECT} with the provided key
|
|
200
|
-
* @param {string} str
|
|
201
|
-
*/
|
|
202
|
-
static key(str: string): string;
|
|
203
|
-
}
|