@ne1410s/codl 0.1.2 → 0.1.4
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/dist/decorate/interception.d.ts +26 -26
- package/dist/decorate/metadata.d.ts +28 -28
- package/dist/decorate/type.d.ts +9 -9
- package/dist/decorate/validation.d.ts +71 -71
- package/dist/index.d.ts +7 -7
- package/dist/mdkeys.d.ts +20 -20
- package/dist/ne14_codl.cjs.min.js +728 -721
- package/dist/ne14_codl.esm.min.js +728 -721
- package/dist/ne14_codl.umd.min.js +728 -721
- package/dist/reflect/metadata.d.ts +24 -24
- package/dist/reflect/type/models.d.ts +1 -1
- package/dist/reflect/type/parsers/boolean.d.ts +2 -2
- package/dist/reflect/type/parsers/date.d.ts +2 -2
- package/dist/reflect/type/parsers/integer.d.ts +2 -2
- package/dist/reflect/type/parsers/number.d.ts +2 -2
- package/dist/reflect/type/type.d.ts +17 -17
- package/dist/reflect/validation/models.d.ts +39 -39
- package/dist/reflect/validation/validation.d.ts +27 -27
- package/dist/reflect/validation/validators/custom.d.ts +3 -3
- package/dist/reflect/validation/validators/forbidden.d.ts +3 -3
- package/dist/reflect/validation/validators/length-range.d.ts +3 -3
- package/dist/reflect/validation/validators/options.d.ts +3 -3
- package/dist/reflect/validation/validators/range.d.ts +3 -3
- package/dist/reflect/validation/validators/regex.d.ts +3 -3
- package/dist/reflect/validation/validators/required.d.ts +3 -3
- package/dist/reflect/validation/validators/type.d.ts +3 -3
- package/dist/types.d.ts +24 -24
- package/package.json +7 -7
|
@@ -1,26 +1,26 @@
|
|
|
1
|
-
import { Ctor, FunctionDecorator, TypedPropertyDecorator } from '../types';
|
|
2
|
-
export declare abstract class Interception {
|
|
3
|
-
/**
|
|
4
|
-
* Calls a custom function each with new instance created.
|
|
5
|
-
* @param fn A custom function.
|
|
6
|
-
*/
|
|
7
|
-
static readonly init: <T>(fn: (o: any) => void) => (c: Ctor<T>) => Ctor<any>;
|
|
8
|
-
/**
|
|
9
|
-
* Provides an initial / default value.
|
|
10
|
-
* @param val The initial value.
|
|
11
|
-
*/
|
|
12
|
-
static readonly initial: <T>(val: T) => TypedPropertyDecorator<T>;
|
|
13
|
-
/**
|
|
14
|
-
* Intercepts the input of a function, preventing its execution.
|
|
15
|
-
* @param fn A custom function.
|
|
16
|
-
* @returns The result of the custom function.
|
|
17
|
-
*/
|
|
18
|
-
static readonly input: (fn: (args: any[], o: any) => any) => FunctionDecorator;
|
|
19
|
-
/**
|
|
20
|
-
* Intercepts the output of a function, after it is executed.
|
|
21
|
-
* @param fn A custom function.
|
|
22
|
-
* @returns The result of the custom function.
|
|
23
|
-
*/
|
|
24
|
-
static readonly output: <T>(fn: (val: T, args: any[], o: any) => T) => FunctionDecorator;
|
|
25
|
-
private static readonly expose;
|
|
26
|
-
}
|
|
1
|
+
import { Ctor, FunctionDecorator, TypedPropertyDecorator } from '../types';
|
|
2
|
+
export declare abstract class Interception {
|
|
3
|
+
/**
|
|
4
|
+
* Calls a custom function each with new instance created.
|
|
5
|
+
* @param fn A custom function.
|
|
6
|
+
*/
|
|
7
|
+
static readonly init: <T>(fn: (o: any) => void) => (c: Ctor<T>) => Ctor<any>;
|
|
8
|
+
/**
|
|
9
|
+
* Provides an initial / default value.
|
|
10
|
+
* @param val The initial value.
|
|
11
|
+
*/
|
|
12
|
+
static readonly initial: <T>(val: T) => TypedPropertyDecorator<T>;
|
|
13
|
+
/**
|
|
14
|
+
* Intercepts the input of a function, preventing its execution.
|
|
15
|
+
* @param fn A custom function.
|
|
16
|
+
* @returns The result of the custom function.
|
|
17
|
+
*/
|
|
18
|
+
static readonly input: (fn: (args: any[], o: any) => any) => FunctionDecorator;
|
|
19
|
+
/**
|
|
20
|
+
* Intercepts the output of a function, after it is executed.
|
|
21
|
+
* @param fn A custom function.
|
|
22
|
+
* @returns The result of the custom function.
|
|
23
|
+
*/
|
|
24
|
+
static readonly output: <T>(fn: (val: T, args: any[], o: any) => T) => FunctionDecorator;
|
|
25
|
+
private static readonly expose;
|
|
26
|
+
}
|
|
@@ -1,28 +1,28 @@
|
|
|
1
|
-
import 'reflect-metadata';
|
|
2
|
-
import { TypedPropertyDecorator, Ctor } from '../types';
|
|
3
|
-
/** Decorators for metadata purposes. */
|
|
4
|
-
export declare abstract class Metadata {
|
|
5
|
-
/**
|
|
6
|
-
* Associates a display name with the member to which it is applied.
|
|
7
|
-
* @param val The name.
|
|
8
|
-
*/
|
|
9
|
-
static readonly displayName: (val: string) => {
|
|
10
|
-
(target: Function): void;
|
|
11
|
-
(target: Object, propertyKey: string | symbol): void;
|
|
12
|
-
};
|
|
13
|
-
/**
|
|
14
|
-
* Associates a description with the member to which it is applied.
|
|
15
|
-
* @param val The description.
|
|
16
|
-
*/
|
|
17
|
-
static readonly description: (val: string) => {
|
|
18
|
-
(target: Function): void;
|
|
19
|
-
(target: Object, propertyKey: string | symbol): void;
|
|
20
|
-
};
|
|
21
|
-
/**
|
|
22
|
-
* Associates a format function with the member to which it is applied.
|
|
23
|
-
* @param fn The format function.
|
|
24
|
-
*/
|
|
25
|
-
static readonly format: <T>(fn: (val: T) => string) => TypedPropertyDecorator<T>;
|
|
26
|
-
/** Associates a child's prototype data on the parent in which it appears. */
|
|
27
|
-
static readonly model: <T extends Object>(ctor: Ctor<T>) => TypedPropertyDecorator<T | T[]>;
|
|
28
|
-
}
|
|
1
|
+
import 'reflect-metadata';
|
|
2
|
+
import { TypedPropertyDecorator, Ctor } from '../types';
|
|
3
|
+
/** Decorators for metadata purposes. */
|
|
4
|
+
export declare abstract class Metadata {
|
|
5
|
+
/**
|
|
6
|
+
* Associates a display name with the member to which it is applied.
|
|
7
|
+
* @param val The name.
|
|
8
|
+
*/
|
|
9
|
+
static readonly displayName: (val: string) => {
|
|
10
|
+
(target: Function): void;
|
|
11
|
+
(target: Object, propertyKey: string | symbol): void;
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* Associates a description with the member to which it is applied.
|
|
15
|
+
* @param val The description.
|
|
16
|
+
*/
|
|
17
|
+
static readonly description: (val: string) => {
|
|
18
|
+
(target: Function): void;
|
|
19
|
+
(target: Object, propertyKey: string | symbol): void;
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* Associates a format function with the member to which it is applied.
|
|
23
|
+
* @param fn The format function.
|
|
24
|
+
*/
|
|
25
|
+
static readonly format: <T>(fn: (val: T) => string) => TypedPropertyDecorator<T>;
|
|
26
|
+
/** Associates a child's prototype data on the parent in which it appears. */
|
|
27
|
+
static readonly model: <T extends Object>(ctor: Ctor<T>) => TypedPropertyDecorator<T | T[]>;
|
|
28
|
+
}
|
package/dist/decorate/type.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import 'reflect-metadata';
|
|
2
|
-
import { TypedPropertyDecorator } from '../types';
|
|
3
|
-
/** Decorators for type purposes. */
|
|
4
|
-
export declare abstract class Type {
|
|
5
|
-
static readonly boolean: TypedPropertyDecorator<boolean | number | string | Array<boolean | number | string>>;
|
|
6
|
-
static readonly date: TypedPropertyDecorator<Date | string | Array<Date | string>>;
|
|
7
|
-
static readonly integer: TypedPropertyDecorator<number | string | Array<number | string>>;
|
|
8
|
-
static readonly number: TypedPropertyDecorator<number | string | Array<number | string>>;
|
|
9
|
-
}
|
|
1
|
+
import 'reflect-metadata';
|
|
2
|
+
import { TypedPropertyDecorator } from '../types';
|
|
3
|
+
/** Decorators for type purposes. */
|
|
4
|
+
export declare abstract class Type {
|
|
5
|
+
static readonly boolean: TypedPropertyDecorator<boolean | number | string | Array<boolean | number | string>>;
|
|
6
|
+
static readonly date: TypedPropertyDecorator<Date | string | Array<Date | string>>;
|
|
7
|
+
static readonly integer: TypedPropertyDecorator<number | string | Array<number | string>>;
|
|
8
|
+
static readonly number: TypedPropertyDecorator<number | string | Array<number | string>>;
|
|
9
|
+
}
|
|
@@ -1,71 +1,71 @@
|
|
|
1
|
-
import 'reflect-metadata';
|
|
2
|
-
import { TypedPropertyDecorator, CustomValidator } from '../types';
|
|
3
|
-
/** Decorators for validation purposes. */
|
|
4
|
-
export declare abstract class Validation {
|
|
5
|
-
/**
|
|
6
|
-
* Makes a property required. 'Unprovided' values (null, undefined, '') are
|
|
7
|
-
* invalid, as is NaN. Anything else is valid (including: 0, 0n, false).
|
|
8
|
-
*/
|
|
9
|
-
static readonly required: PropertyDecorator;
|
|
10
|
-
/**
|
|
11
|
-
* Makes a property forbidden. 'Unprovided' values (null, undefined, '') are
|
|
12
|
-
* valid. Anything else is considered invalid (including: 0, 0n, false).
|
|
13
|
-
*/
|
|
14
|
-
static readonly forbidden: PropertyDecorator;
|
|
15
|
-
/**
|
|
16
|
-
* Associates a string or array with a minimum length. 'Unprovided' values
|
|
17
|
-
* (null, undefined, '') are not tested hence valid. Otherwise the string
|
|
18
|
-
* length must not be less than the bound supplied.
|
|
19
|
-
* @param lBound The minimum length.
|
|
20
|
-
*/
|
|
21
|
-
static readonly minLength: <T>(lBound: number) => TypedPropertyDecorator<ArrayLike<T>>;
|
|
22
|
-
/**
|
|
23
|
-
* Associates a string or array with a maximum length. 'Unprovided' values
|
|
24
|
-
* (null, undefined, '') are not tested hence valid. Otherwise the string
|
|
25
|
-
* length must not exceed the upper bound supplied.
|
|
26
|
-
* @param uBound The maximum length.
|
|
27
|
-
*/
|
|
28
|
-
static readonly maxLength: <T>(uBound: number) => TypedPropertyDecorator<ArrayLike<T>>;
|
|
29
|
-
/**
|
|
30
|
-
* Associates a property with a minimum value. 'Unprovided' values (null,
|
|
31
|
-
* undefined, '') are not tested hence valid. Otherwise the value must not be
|
|
32
|
-
* less than the lower bound supplied to be valid.
|
|
33
|
-
* @param lBound The minimum value.
|
|
34
|
-
*/
|
|
35
|
-
static readonly min: <T extends Number | Date>(lBound: T) => TypedPropertyDecorator<T | ArrayLike<T>>;
|
|
36
|
-
/**
|
|
37
|
-
* Associates a number or date property with a maximum value. 'Unprovided'
|
|
38
|
-
* values (null, undefined, '') are not tested hence valid. Otherwise the
|
|
39
|
-
* value must not exceed the upper bound supplied to be valid.
|
|
40
|
-
* @param uBound The maximum value.
|
|
41
|
-
*/
|
|
42
|
-
static readonly max: <T extends Number | Date>(uBound: T) => TypedPropertyDecorator<T | ArrayLike<T>>;
|
|
43
|
-
/**
|
|
44
|
-
* Associates a property with minimum and maximum values. 'Unprovided' values
|
|
45
|
-
* (null, undefined, '') are not tested hence valid. Otherwise the value must
|
|
46
|
-
* be (inclusively) between the lower and upper bounds.
|
|
47
|
-
* @param lBound The minimum value.
|
|
48
|
-
*/
|
|
49
|
-
static readonly range: <T extends Number | Date>(lBound: T, uBound: T) => TypedPropertyDecorator<T | ArrayLike<T>>;
|
|
50
|
-
/**
|
|
51
|
-
* Associates a property with a pattern. 'Unprovided' values (null, undefined,
|
|
52
|
-
* '') are not tested hence valid. Otherwise the result of .toString() must
|
|
53
|
-
* match the regex supplied to be valid.
|
|
54
|
-
* @param regex The validation pattern.
|
|
55
|
-
*/
|
|
56
|
-
static readonly regex: (regex: string | RegExp) => PropertyDecorator;
|
|
57
|
-
/**
|
|
58
|
-
* Associates a property with a predefined set of allowed values. Primitive
|
|
59
|
-
* types, enums and arrays thereof are all supported.
|
|
60
|
-
*/
|
|
61
|
-
static readonly options: <T extends String | Number | Boolean>(...opts: T[]) => TypedPropertyDecorator<T | ArrayLike<T>>;
|
|
62
|
-
/**
|
|
63
|
-
* Associates a property with a custom validator. Unlike most other validation
|
|
64
|
-
* decorators, ALL values will be tested (rather than being skipped if it was
|
|
65
|
-
* deemed 'unprovided') - the decision is not taken on the caller's behalf. If
|
|
66
|
-
* the function returns false, the value is deemed invalid and a generic error
|
|
67
|
-
* is used. Else if it returns a string, this string is used as the message,
|
|
68
|
-
* with null or empty strings taken to indicate that the value is valid).
|
|
69
|
-
*/
|
|
70
|
-
static readonly custom: <T>(fn: CustomValidator) => TypedPropertyDecorator<T>;
|
|
71
|
-
}
|
|
1
|
+
import 'reflect-metadata';
|
|
2
|
+
import { TypedPropertyDecorator, CustomValidator } from '../types';
|
|
3
|
+
/** Decorators for validation purposes. */
|
|
4
|
+
export declare abstract class Validation {
|
|
5
|
+
/**
|
|
6
|
+
* Makes a property required. 'Unprovided' values (null, undefined, '') are
|
|
7
|
+
* invalid, as is NaN. Anything else is valid (including: 0, 0n, false).
|
|
8
|
+
*/
|
|
9
|
+
static readonly required: PropertyDecorator;
|
|
10
|
+
/**
|
|
11
|
+
* Makes a property forbidden. 'Unprovided' values (null, undefined, '') are
|
|
12
|
+
* valid. Anything else is considered invalid (including: 0, 0n, false).
|
|
13
|
+
*/
|
|
14
|
+
static readonly forbidden: PropertyDecorator;
|
|
15
|
+
/**
|
|
16
|
+
* Associates a string or array with a minimum length. 'Unprovided' values
|
|
17
|
+
* (null, undefined, '') are not tested hence valid. Otherwise the string
|
|
18
|
+
* length must not be less than the bound supplied.
|
|
19
|
+
* @param lBound The minimum length.
|
|
20
|
+
*/
|
|
21
|
+
static readonly minLength: <T>(lBound: number) => TypedPropertyDecorator<ArrayLike<T>>;
|
|
22
|
+
/**
|
|
23
|
+
* Associates a string or array with a maximum length. 'Unprovided' values
|
|
24
|
+
* (null, undefined, '') are not tested hence valid. Otherwise the string
|
|
25
|
+
* length must not exceed the upper bound supplied.
|
|
26
|
+
* @param uBound The maximum length.
|
|
27
|
+
*/
|
|
28
|
+
static readonly maxLength: <T>(uBound: number) => TypedPropertyDecorator<ArrayLike<T>>;
|
|
29
|
+
/**
|
|
30
|
+
* Associates a property with a minimum value. 'Unprovided' values (null,
|
|
31
|
+
* undefined, '') are not tested hence valid. Otherwise the value must not be
|
|
32
|
+
* less than the lower bound supplied to be valid.
|
|
33
|
+
* @param lBound The minimum value.
|
|
34
|
+
*/
|
|
35
|
+
static readonly min: <T extends Number | Date>(lBound: T) => TypedPropertyDecorator<T | ArrayLike<T>>;
|
|
36
|
+
/**
|
|
37
|
+
* Associates a number or date property with a maximum value. 'Unprovided'
|
|
38
|
+
* values (null, undefined, '') are not tested hence valid. Otherwise the
|
|
39
|
+
* value must not exceed the upper bound supplied to be valid.
|
|
40
|
+
* @param uBound The maximum value.
|
|
41
|
+
*/
|
|
42
|
+
static readonly max: <T extends Number | Date>(uBound: T) => TypedPropertyDecorator<T | ArrayLike<T>>;
|
|
43
|
+
/**
|
|
44
|
+
* Associates a property with minimum and maximum values. 'Unprovided' values
|
|
45
|
+
* (null, undefined, '') are not tested hence valid. Otherwise the value must
|
|
46
|
+
* be (inclusively) between the lower and upper bounds.
|
|
47
|
+
* @param lBound The minimum value.
|
|
48
|
+
*/
|
|
49
|
+
static readonly range: <T extends Number | Date>(lBound: T, uBound: T) => TypedPropertyDecorator<T | ArrayLike<T>>;
|
|
50
|
+
/**
|
|
51
|
+
* Associates a property with a pattern. 'Unprovided' values (null, undefined,
|
|
52
|
+
* '') are not tested hence valid. Otherwise the result of .toString() must
|
|
53
|
+
* match the regex supplied to be valid.
|
|
54
|
+
* @param regex The validation pattern.
|
|
55
|
+
*/
|
|
56
|
+
static readonly regex: (regex: string | RegExp) => PropertyDecorator;
|
|
57
|
+
/**
|
|
58
|
+
* Associates a property with a predefined set of allowed values. Primitive
|
|
59
|
+
* types, enums and arrays thereof are all supported.
|
|
60
|
+
*/
|
|
61
|
+
static readonly options: <T extends String | Number | Boolean>(...opts: T[]) => TypedPropertyDecorator<T | ArrayLike<T>>;
|
|
62
|
+
/**
|
|
63
|
+
* Associates a property with a custom validator. Unlike most other validation
|
|
64
|
+
* decorators, ALL values will be tested (rather than being skipped if it was
|
|
65
|
+
* deemed 'unprovided') - the decision is not taken on the caller's behalf. If
|
|
66
|
+
* the function returns false, the value is deemed invalid and a generic error
|
|
67
|
+
* is used. Else if it returns a string, this string is used as the message,
|
|
68
|
+
* with null or empty strings taken to indicate that the value is valid).
|
|
69
|
+
*/
|
|
70
|
+
static readonly custom: <T>(fn: CustomValidator) => TypedPropertyDecorator<T>;
|
|
71
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export * from './types';
|
|
2
|
-
export * from './decorate/interception';
|
|
3
|
-
export * from './decorate/metadata';
|
|
4
|
-
export * from './decorate/type';
|
|
5
|
-
export * from './decorate/validation';
|
|
6
|
-
export * from './reflect/metadata';
|
|
7
|
-
export * from './reflect/validation/validation';
|
|
1
|
+
export * from './types';
|
|
2
|
+
export * from './decorate/interception';
|
|
3
|
+
export * from './decorate/metadata';
|
|
4
|
+
export * from './decorate/type';
|
|
5
|
+
export * from './decorate/validation';
|
|
6
|
+
export * from './reflect/metadata';
|
|
7
|
+
export * from './reflect/validation/validation';
|
package/dist/mdkeys.d.ts
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
/** Metadata keys. */
|
|
2
|
-
export declare enum MetadataKey {
|
|
3
|
-
DISPLAY_NAME = "ne-codl:metadata:display-name",
|
|
4
|
-
DESCRIPTION = "ne-codl:metadata:description",
|
|
5
|
-
FORMAT = "ne-codl:metadata:format",
|
|
6
|
-
MODEL = "ne-codl:metadata:model"
|
|
7
|
-
}
|
|
8
|
-
/** Validation keys. */
|
|
9
|
-
export declare enum ValidationKey {
|
|
10
|
-
REQUIRED = "ne-codl:validation:required",
|
|
11
|
-
FORBIDDEN = "ne-codl:validation:forbidden",
|
|
12
|
-
MIN_LENGTH = "ne-codl:validation:min-length",
|
|
13
|
-
MAX_LENGTH = "ne-codl:validation:max-length",
|
|
14
|
-
MIN = "ne-codl:validation:min",
|
|
15
|
-
MAX = "ne-codl:validation:max",
|
|
16
|
-
REGEX = "ne-codl:validation:regex",
|
|
17
|
-
TYPE = "ne-codl:validation:type",
|
|
18
|
-
OPTIONS = "ne-codl:validation:options",
|
|
19
|
-
CUSTOM = "ne-codl:validation:custom"
|
|
20
|
-
}
|
|
1
|
+
/** Metadata keys. */
|
|
2
|
+
export declare enum MetadataKey {
|
|
3
|
+
DISPLAY_NAME = "ne-codl:metadata:display-name",
|
|
4
|
+
DESCRIPTION = "ne-codl:metadata:description",
|
|
5
|
+
FORMAT = "ne-codl:metadata:format",
|
|
6
|
+
MODEL = "ne-codl:metadata:model"
|
|
7
|
+
}
|
|
8
|
+
/** Validation keys. */
|
|
9
|
+
export declare enum ValidationKey {
|
|
10
|
+
REQUIRED = "ne-codl:validation:required",
|
|
11
|
+
FORBIDDEN = "ne-codl:validation:forbidden",
|
|
12
|
+
MIN_LENGTH = "ne-codl:validation:min-length",
|
|
13
|
+
MAX_LENGTH = "ne-codl:validation:max-length",
|
|
14
|
+
MIN = "ne-codl:validation:min",
|
|
15
|
+
MAX = "ne-codl:validation:max",
|
|
16
|
+
REGEX = "ne-codl:validation:regex",
|
|
17
|
+
TYPE = "ne-codl:validation:type",
|
|
18
|
+
OPTIONS = "ne-codl:validation:options",
|
|
19
|
+
CUSTOM = "ne-codl:validation:custom"
|
|
20
|
+
}
|