@thisisagile/easy 17.34.3 → 17.35.0
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/{chunk-JDNKYQAV.mjs → chunk-EDH6XY6O.mjs} +3 -1
- package/dist/chunk-EDH6XY6O.mjs.map +1 -0
- package/dist/{chunk-G2H4MJUT.mjs → chunk-Y3QJPP25.mjs} +2 -2
- package/dist/domain/Audit.mjs +2 -2
- package/dist/domain/Child.mjs +1 -1
- package/dist/domain/Entity.mjs +2 -2
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -1
- package/dist/validation/Contraints.d.ts +1 -0
- package/dist/validation/Contraints.mjs +3 -1
- package/package.json +1 -1
- package/src/validation/Contraints.ts +3 -0
- package/dist/chunk-JDNKYQAV.mjs.map +0 -1
- /package/dist/{chunk-G2H4MJUT.mjs.map → chunk-Y3QJPP25.mjs.map} +0 -0
|
@@ -11,6 +11,7 @@ export declare const optional: () => PropertyDecorator;
|
|
|
11
11
|
export declare const includes: (sub: string, message?: string) => PropertyDecorator;
|
|
12
12
|
export declare const inList: (values: unknown[], message?: Text) => PropertyDecorator;
|
|
13
13
|
export declare const inOptionalList: (values: unknown[], message?: Text) => PropertyDecorator;
|
|
14
|
+
export declare const inUnion: (values: readonly unknown[], message?: Text) => PropertyDecorator;
|
|
14
15
|
export declare const gt: (limit: number, message?: Text) => PropertyDecorator;
|
|
15
16
|
export declare const gte: (limit: number, message?: Text) => PropertyDecorator;
|
|
16
17
|
export declare const lt: (limit: number, message?: Text) => PropertyDecorator;
|
|
@@ -6,6 +6,7 @@ import {
|
|
|
6
6
|
gte,
|
|
7
7
|
inList,
|
|
8
8
|
inOptionalList,
|
|
9
|
+
inUnion,
|
|
9
10
|
includes,
|
|
10
11
|
lt,
|
|
11
12
|
lte,
|
|
@@ -17,7 +18,7 @@ import {
|
|
|
17
18
|
required,
|
|
18
19
|
rule,
|
|
19
20
|
valid
|
|
20
|
-
} from "../chunk-
|
|
21
|
+
} from "../chunk-EDH6XY6O.mjs";
|
|
21
22
|
import "../chunk-ADJAEGCT.mjs";
|
|
22
23
|
import "../chunk-Y27OR4OA.mjs";
|
|
23
24
|
import "../chunk-OFGI5FLG.mjs";
|
|
@@ -45,6 +46,7 @@ export {
|
|
|
45
46
|
gte,
|
|
46
47
|
inList,
|
|
47
48
|
inOptionalList,
|
|
49
|
+
inUnion,
|
|
48
50
|
includes,
|
|
49
51
|
lt,
|
|
50
52
|
lte,
|
package/package.json
CHANGED
|
@@ -40,6 +40,9 @@ export const inList = (values: unknown[], message?: Text): PropertyDecorator =>
|
|
|
40
40
|
export const inOptionalList = (values: unknown[], message?: Text): PropertyDecorator =>
|
|
41
41
|
constraint(v => !isDefined(v) || isIn(v, values), message ?? 'Value {actual} must appear in list.');
|
|
42
42
|
|
|
43
|
+
export const inUnion = (values: readonly unknown[], message?: Text): PropertyDecorator =>
|
|
44
|
+
constraint(v => isDefined(v) && isIn(v, [...values]), message ?? 'Value {actual} must be in union.');
|
|
45
|
+
|
|
43
46
|
export const gt = (limit: number, message?: Text): PropertyDecorator => constraint(v => v > limit, message ?? `Value {actual} must be larger than '${limit}'.`);
|
|
44
47
|
|
|
45
48
|
export const gte = (limit: number, message?: Text): PropertyDecorator =>
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/validation/Contraints.ts"],"sourcesContent":["import { validate, Validator } from './Validate';\nimport { Func } from '../types/Func';\nimport { Results } from '../types/Results';\nimport { meta } from '../types/Meta';\nimport { List, toList } from '../types/List';\nimport { isBoolean, isDefined, isFunction, isIn, isNotEmpty, isString } from '../types/Is';\nimport { tryTo } from '../types/Try';\nimport { inFuture, inPast } from '../types/IsDate';\nimport type { Text } from '../types/Text';\nimport { text } from '../types/ToText';\n\nexport type Constraint = Func<boolean | Results, any>;\n\nexport const constraint =\n <T>(c: Constraint, message: Text): PropertyDecorator =>\n (subject: unknown, property: string | symbol): void => {\n const cs = meta(subject).property(property).get<List<Validator>>('constraint') ?? toList<Validator>();\n meta(subject)\n .property(property)\n .set('constraint', cs.add({ property, constraint: c, text: message }));\n };\n\nexport const defined = (message?: Text): PropertyDecorator => constraint(v => isDefined(v), message ?? 'Property {property} must be defined.');\n\nexport const required = (message?: Text): PropertyDecorator =>\n constraint(v => isNotEmpty(v), message ?? 'Property {property} is required, and may not be empty.');\n\nexport const notEmpty = (message?: Text): PropertyDecorator => constraint(v => isNotEmpty(v), message ?? 'Property {property} may not be empty.');\n\nexport const valid = (): PropertyDecorator => constraint(v => validate(v), '');\n\nexport const optional = (): PropertyDecorator => constraint(v => !isDefined(v) || validate(v), '');\n\nexport const includes = (sub: string, message?: string): PropertyDecorator =>\n constraint(s => isDefined(s) && isString(s) && s.includes(sub), message ?? `Value {actual} must include '${sub}'.`);\n\nexport const inList = (values: unknown[], message?: Text): PropertyDecorator =>\n constraint(v => isDefined(v) && isIn(v, values), message ?? 'Value {actual} must appear in list.');\n\nexport const inOptionalList = (values: unknown[], message?: Text): PropertyDecorator =>\n constraint(v => !isDefined(v) || isIn(v, values), message ?? 'Value {actual} must appear in list.');\n\nexport const gt = (limit: number, message?: Text): PropertyDecorator => constraint(v => v > limit, message ?? `Value {actual} must be larger than '${limit}'.`);\n\nexport const gte = (limit: number, message?: Text): PropertyDecorator =>\n constraint(v => v >= limit, message ?? `Value {actual} must be larger than or equal to ${limit}.`);\n\nexport const lt = (limit: number, message?: Text): PropertyDecorator => constraint(v => v < limit, message ?? `Value {actual} must be smaller than ${limit}.`);\n\nexport const lte = (limit: number, message?: Text): PropertyDecorator =>\n constraint(v => v <= limit, message ?? `Value {actual} must be smaller than or equal to ${limit}.`);\n\nexport const past = (message?: Text): PropertyDecorator => constraint(v => inPast(v), message ?? 'Value {actual} must lay in the past.');\n\nexport const future = (message?: Text): PropertyDecorator => constraint(v => inFuture(v), message ?? 'Value {actual} must lay in the future.');\n\nexport const minLength = (length: number, message?: Text): PropertyDecorator =>\n constraint(\n v =>\n tryTo(() => v)\n .is.defined()\n .map(v => text(v).toString().length >= length)\n .orElse(true) as boolean,\n message ?? `Value {actual} must be at least '${length}' characters long.`\n );\n\nexport const maxLength = (length: number, message?: Text): PropertyDecorator =>\n constraint(\n v =>\n tryTo(() => v)\n .is.defined()\n .map(v => text(v).toString().length <= length)\n .orElse(true) as boolean,\n message ?? `Value {actual} cannot be longer than '${length}' characters.`\n );\n\nexport const rule = (message?: Text): PropertyDecorator =>\n constraint(v => (isFunction(v) ? (v() as boolean | Results) : isBoolean(v) ? v : false), message ?? `Value {actual} must be true`);\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAaO,IAAM,aACX,CAAI,GAAe,YACnB,CAAC,SAAkB,aAAoC;AACrD,QAAM,KAAK,KAAK,OAAO,EAAE,SAAS,QAAQ,EAAE,IAAqB,YAAY,KAAK,OAAkB;AACpG,OAAK,OAAO,EACT,SAAS,QAAQ,EACjB,IAAI,cAAc,GAAG,IAAI,EAAE,UAAU,YAAY,GAAG,MAAM,QAAQ,CAAC,CAAC;AACzE;AAEK,IAAM,UAAU,CAAC,YAAsC,WAAW,OAAK,UAAU,CAAC,GAAG,WAAW,sCAAsC;AAEtI,IAAM,WAAW,CAAC,YACvB,WAAW,OAAK,WAAW,CAAC,GAAG,WAAW,wDAAwD;AAE7F,IAAM,WAAW,CAAC,YAAsC,WAAW,OAAK,WAAW,CAAC,GAAG,WAAW,uCAAuC;AAEzI,IAAM,QAAQ,MAAyB,WAAW,OAAK,SAAS,CAAC,GAAG,EAAE;AAEtE,IAAM,WAAW,MAAyB,WAAW,OAAK,CAAC,UAAU,CAAC,KAAK,SAAS,CAAC,GAAG,EAAE;AAE1F,IAAM,WAAW,CAAC,KAAa,YACpC,WAAW,OAAK,UAAU,CAAC,KAAK,SAAS,CAAC,KAAK,EAAE,SAAS,GAAG,GAAG,WAAW,gCAAgC,GAAG,IAAI;AAE7G,IAAM,SAAS,CAAC,QAAmB,YACxC,WAAW,OAAK,UAAU,CAAC,KAAK,KAAK,G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