validno 0.3.5 → 0.4.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/Schema.d.ts +10 -0
- package/dist/Schema.d.ts.map +1 -0
- package/dist/constants/details.d.ts +11 -0
- package/dist/constants/details.d.ts.map +1 -0
- package/dist/constants/schema.d.ts +10 -0
- package/dist/constants/schema.d.ts.map +1 -0
- package/dist/dev.d.ts +2 -0
- package/dist/dev.d.ts.map +1 -0
- package/dist/engine/ValidateEngine.d.ts +30 -0
- package/dist/engine/ValidateEngine.d.ts.map +1 -0
- package/dist/engine/ValidnoResult.d.ts +41 -0
- package/dist/engine/ValidnoResult.d.ts.map +1 -0
- package/dist/engine/index.d.ts +3 -0
- package/dist/engine/index.d.ts.map +1 -0
- package/dist/engine/methods/finishValidation.d.ts +11 -0
- package/dist/engine/methods/finishValidation.d.ts.map +1 -0
- package/dist/engine/methods/handleKey.d.ts +14 -0
- package/dist/engine/methods/handleKey.d.ts.map +1 -0
- package/dist/engine/methods/handleMissingKey.d.ts +5 -0
- package/dist/engine/methods/handleMissingKey.d.ts.map +1 -0
- package/dist/engine/methods/handleMissingKeyValidation.d.ts +14 -0
- package/dist/engine/methods/handleMissingKeyValidation.d.ts.map +1 -0
- package/dist/engine/methods/handleNestedKey.d.ts +4 -0
- package/dist/engine/methods/handleNestedKey.d.ts.map +1 -0
- package/dist/engine/methods/validate.d.ts +5 -0
- package/dist/engine/methods/validate.d.ts.map +1 -0
- package/dist/engine/methods/validateRules.d.ts +19 -0
- package/dist/engine/methods/validateRules.d.ts.map +1 -0
- package/dist/engine/methods/validateType.d.ts +13 -0
- package/dist/engine/methods/validateType.d.ts.map +1 -0
- package/dist/index.d.ts +47 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +2 -0
- package/dist/types/common.d.ts +21 -0
- package/dist/types/common.d.ts.map +1 -0
- package/dist/utils/errors.d.ts +15 -0
- package/dist/utils/errors.d.ts.map +1 -0
- package/dist/utils/helpers.d.ts +24 -0
- package/dist/utils/helpers.d.ts.map +1 -0
- package/dist/utils/isObjectId.d.ts +3 -0
- package/dist/utils/isObjectId.d.ts.map +1 -0
- package/dist/utils/validateType.d.ts +14 -0
- package/dist/utils/validateType.d.ts.map +1 -0
- package/dist/utils/validations.d.ts +87 -0
- package/dist/utils/validations.d.ts.map +1 -0
- package/package.json +15 -3
- package/nodemon.json +0 -4
package/dist/Schema.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { SchemaFields } from "./constants/schema.js";
|
|
2
|
+
import { SchemaDefinition } from "./types/common.js";
|
|
3
|
+
import ValidnoResult from "./engine/ValidnoResult.js";
|
|
4
|
+
export declare const defaultSchemaKeys: SchemaFields[];
|
|
5
|
+
export declare class Schema {
|
|
6
|
+
definition: SchemaDefinition;
|
|
7
|
+
constructor(inputSchemaDefinition: SchemaDefinition);
|
|
8
|
+
validate<T, K extends keyof T = keyof T>(inputData: T, validationKeys?: K | K[]): ValidnoResult;
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=Schema.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Schema.d.ts","sourceRoot":"","sources":["../src/Schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAA;AACpD,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAErD,OAAO,aAAa,MAAM,2BAA2B,CAAC;AAEtD,eAAO,MAAM,iBAAiB,gBAA8B,CAAC;AAE7D,qBAAa,MAAM;IACf,UAAU,EAAE,gBAAgB,CAAA;gBAEhB,qBAAqB,EAAE,gBAAgB;IAQnD,QAAQ,CAAC,CAAC,EAAE,CAAC,SAAS,MAAM,CAAC,GAAG,MAAM,CAAC,EAAE,SAAS,EAAE,CAAC,EAAE,cAAc,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,GAAG,aAAa;CAKlG"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export declare enum ValidationIds {
|
|
2
|
+
Missing = "missing",
|
|
3
|
+
Type = "type",
|
|
4
|
+
Rule = "rule"
|
|
5
|
+
}
|
|
6
|
+
export declare enum ValidationDetails {
|
|
7
|
+
OK = "OK",
|
|
8
|
+
INVALID_DATE = "Invalid date",
|
|
9
|
+
CustomRuleFailed = "Custom rule failed"
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=details.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"details.d.ts","sourceRoot":"","sources":["../../src/constants/details.ts"],"names":[],"mappings":"AAAA,oBAAY,aAAa;IACrB,OAAO,YAAY;IACnB,IAAI,SAAS;IACb,IAAI,SAAS;CAChB;AAED,oBAAY,iBAAiB;IACzB,EAAE,OAAO;IACT,YAAY,iBAAiB;IAC7B,gBAAgB,uBAAuB;CAC1C"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../src/constants/schema.ts"],"names":[],"mappings":"AAAA,oBAAY,YAAY;IACpB,QAAQ,aAAa;IACrB,IAAI,SAAS;IACb,QAAQ,aAAa;IACrB,KAAK,UAAU;IACf,KAAK,UAAU;IACf,aAAa,kBAAkB;IAC/B,UAAU,eAAe;CAC5B"}
|
package/dist/dev.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dev.d.ts","sourceRoot":"","sources":["../src/dev.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { Schema } from "../Schema.js";
|
|
2
|
+
import ValidnoResult from "./ValidnoResult.js";
|
|
3
|
+
import { SchemaDefinition } from "../types/common.js";
|
|
4
|
+
import { ValidateValueInput } from "./methods/validateType.js";
|
|
5
|
+
import { ValidateRulesInput } from "./methods/validateRules.js";
|
|
6
|
+
import { HandleMissingKeyValidationParams } from "./methods/handleMissingKeyValidation.js";
|
|
7
|
+
import { FinalizeValidationInput } from "./methods/finishValidation.js";
|
|
8
|
+
export interface KeyValidationDetails {
|
|
9
|
+
results: ValidnoResult;
|
|
10
|
+
key: string;
|
|
11
|
+
data: any;
|
|
12
|
+
reqs: SchemaDefinition;
|
|
13
|
+
nestedKey: string;
|
|
14
|
+
}
|
|
15
|
+
declare class ValidateEngine {
|
|
16
|
+
definition: SchemaDefinition;
|
|
17
|
+
result: ValidnoResult;
|
|
18
|
+
constructor(definition: SchemaDefinition);
|
|
19
|
+
validate(data: any, validationKeys?: string | string[]): ValidnoResult;
|
|
20
|
+
handleKey(input: KeyValidationDetails): ValidnoResult;
|
|
21
|
+
handleNestedKey(input: KeyValidationDetails): ValidnoResult;
|
|
22
|
+
handleMissingKey(schema: Schema, input: KeyValidationDetails): any;
|
|
23
|
+
handleMissingNestedKey(nestedKey: string, results: ValidnoResult): ValidnoResult;
|
|
24
|
+
handleMissingKeyValidation(params: HandleMissingKeyValidationParams): ValidnoResult;
|
|
25
|
+
validateType(input: ValidateValueInput): void;
|
|
26
|
+
validateRules(input: ValidateRulesInput): void;
|
|
27
|
+
finishValidation(checks: FinalizeValidationInput): ValidnoResult;
|
|
28
|
+
}
|
|
29
|
+
export default ValidateEngine;
|
|
30
|
+
//# sourceMappingURL=ValidateEngine.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ValidateEngine.d.ts","sourceRoot":"","sources":["../../src/engine/ValidateEngine.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AACtC,OAAO,aAAa,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAQtD,OAAqB,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAC7E,OAAsB,EAAC,kBAAkB,EAAC,MAAM,4BAA4B,CAAC;AAI7E,OAAmC,EAAE,gCAAgC,EAAE,MAAM,yCAAyC,CAAC;AACvH,OAAyB,EAAE,uBAAuB,EAAE,MAAM,+BAA+B,CAAC;AAE1F,MAAM,WAAW,oBAAoB;IACnC,OAAO,EAAE,aAAa,CAAC;IACvB,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,GAAG,CAAC;IACV,IAAI,EAAE,gBAAgB,CAAC;IACvB,SAAS,EAAE,MAAM,CAAA;CAClB;AAED,cAAM,cAAc;IAClB,UAAU,EAAE,gBAAgB,CAAC;IAC7B,MAAM,EAAE,aAAa,CAAC;gBAEZ,UAAU,EAAE,gBAAgB;IAKtC,QAAQ,CAAC,IAAI,EAAE,GAAG,EAAE,cAAc,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,aAAa;IAItE,SAAS,CAAC,KAAK,EAAE,oBAAoB;IAIrC,eAAe,CAAC,KAAK,EAAE,oBAAoB;IAI3C,gBAAgB,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,oBAAoB;IAI5D,sBAAsB,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,aAAa;IAKhE,0BAA0B,CAAC,MAAM,EAAE,gCAAgC;IAInE,YAAY,CAAC,KAAK,EAAE,kBAAkB;IAItC,aAAa,CAAC,KAAK,EAAE,kBAAkB;IAIvC,gBAAgB,CAAC,MAAM,EAAE,uBAAuB;CAGjD;AAED,eAAe,cAAc,CAAC"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
export interface ResultInput {
|
|
2
|
+
ok: null | boolean;
|
|
3
|
+
missed: string[];
|
|
4
|
+
failed: string[];
|
|
5
|
+
passed: string[];
|
|
6
|
+
errors: string[];
|
|
7
|
+
byKeys: {
|
|
8
|
+
[key: string]: boolean;
|
|
9
|
+
};
|
|
10
|
+
errorsByKeys: {
|
|
11
|
+
[key: string]: string[];
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
declare class ValidnoResult {
|
|
15
|
+
ok: null | boolean;
|
|
16
|
+
missed: string[];
|
|
17
|
+
failed: string[];
|
|
18
|
+
passed: string[];
|
|
19
|
+
errors: string[];
|
|
20
|
+
byKeys: {
|
|
21
|
+
[key: string]: boolean;
|
|
22
|
+
};
|
|
23
|
+
errorsByKeys: {
|
|
24
|
+
[key: string]: string[];
|
|
25
|
+
};
|
|
26
|
+
constructor(results?: ResultInput);
|
|
27
|
+
setNoData(key: string): void;
|
|
28
|
+
setKeyStatus(key: string, result: boolean): void;
|
|
29
|
+
fixParentByChilds(parentKey: string, childChecks?: boolean[]): void;
|
|
30
|
+
setMissing(key: string, errMsg?: string): void;
|
|
31
|
+
setPassed(key: string): void;
|
|
32
|
+
setFailed(key: string, msg?: string): void;
|
|
33
|
+
joinErrors(separator?: string): string;
|
|
34
|
+
merge(resultsNew: ResultInput): ValidnoResult;
|
|
35
|
+
clearEmptyErrorsByKeys(): void;
|
|
36
|
+
finish(): ValidnoResult;
|
|
37
|
+
data(): ResultInput;
|
|
38
|
+
isValid(): boolean;
|
|
39
|
+
}
|
|
40
|
+
export default ValidnoResult;
|
|
41
|
+
//# sourceMappingURL=ValidnoResult.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ValidnoResult.d.ts","sourceRoot":"","sources":["../../src/engine/ValidnoResult.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,WAAW;IAC1B,EAAE,EAAE,IAAI,GAAG,OAAO,CAAC;IACnB,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,MAAM,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;KAAE,CAAC;IACnC,YAAY,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,EAAE,CAAA;KAAE,CAAC;CAC3C;AAED,cAAM,aAAa;IACjB,EAAE,EAAE,IAAI,GAAG,OAAO,CAAC;IACnB,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,MAAM,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;KAAE,CAAC;IACnC,YAAY,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,EAAE,CAAA;KAAE,CAAC;gBAE9B,OAAO,CAAC,EAAE,WAAW;IAUjC,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI;IAK5B,YAAY,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,GAAG,IAAI;IAIhD,iBAAiB,CAAC,SAAS,EAAE,MAAM,EAAE,WAAW,GAAE,OAAO,EAAO,GAAG,IAAI;IAQvE,UAAU,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI;IAQ9C,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI;IAK5B,SAAS,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,MAAM,GAAG,IAAI;IAc1C,UAAU,CAAC,SAAS,SAAO,GAAG,MAAM;IAIpC,KAAK,CAAC,UAAU,EAAE,WAAW,GAAG,aAAa;IAqB7C,sBAAsB,IAAI,IAAI;IAQ9B,MAAM,IAAI,aAAa;IAYvB,IAAI,IAAI,WAAW;IAYnB,OAAO,IAAI,OAAO;CAGnB;AAED,eAAe,aAAa,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/engine/index.ts"],"names":[],"mappings":"AAAA,OAAO,cAAc,MAAM,qBAAqB,CAAC;AAEjD,eAAe,cAAc,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import ValidnoResult from "../ValidnoResult.js";
|
|
2
|
+
export interface FinalizeValidationInput {
|
|
3
|
+
results: ValidnoResult;
|
|
4
|
+
nestedKey: string;
|
|
5
|
+
missedCheck: boolean[];
|
|
6
|
+
typeChecked: boolean[];
|
|
7
|
+
rulesChecked: boolean[];
|
|
8
|
+
}
|
|
9
|
+
declare function finishValidation(checks: FinalizeValidationInput): ValidnoResult;
|
|
10
|
+
export default finishValidation;
|
|
11
|
+
//# sourceMappingURL=finishValidation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"finishValidation.d.ts","sourceRoot":"","sources":["../../../src/engine/methods/finishValidation.ts"],"names":[],"mappings":"AAAA,OAAO,aAAa,MAAM,qBAAqB,CAAC;AAEhD,MAAM,WAAW,uBAAuB;IACtC,OAAO,EAAE,aAAa,CAAC;IACvB,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,OAAO,EAAE,CAAC;IACvB,WAAW,EAAE,OAAO,EAAE,CAAC;IACvB,YAAY,EAAE,OAAO,EAAE,CAAA;CACxB;AAED,iBAAS,gBAAgB,CAAC,MAAM,EAAE,uBAAuB,iBAexD;AAED,eAAe,gBAAgB,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import ValidnoResult from "../ValidnoResult.js";
|
|
2
|
+
import { SchemaDefinition } from "../../types/common.js";
|
|
3
|
+
import ValidateEngine, { KeyValidationDetails } from "../ValidateEngine.js";
|
|
4
|
+
export interface ValidateKeyDetailsParams {
|
|
5
|
+
results: ValidnoResult;
|
|
6
|
+
key: string;
|
|
7
|
+
nestedKey: string;
|
|
8
|
+
data: any;
|
|
9
|
+
reqs: SchemaDefinition;
|
|
10
|
+
hasMissing: boolean;
|
|
11
|
+
}
|
|
12
|
+
declare function validateKey(this: ValidateEngine, input: KeyValidationDetails): ValidnoResult;
|
|
13
|
+
export default validateKey;
|
|
14
|
+
//# sourceMappingURL=handleKey.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"handleKey.d.ts","sourceRoot":"","sources":["../../../src/engine/methods/handleKey.ts"],"names":[],"mappings":"AACA,OAAO,aAAa,MAAM,qBAAqB,CAAC;AAChD,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,cAAc,EAAE,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAE5E,MAAM,WAAW,wBAAwB;IACrC,OAAO,EAAE,aAAa,CAAC;IACvB,GAAG,EAAE,MAAM,CAAC;IACZ,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,GAAG,CAAC;IACV,IAAI,EAAE,gBAAgB,CAAC;IACvB,UAAU,EAAE,OAAO,CAAC;CACvB;AAqBD,iBAAS,WAAW,CAAC,IAAI,EAAE,cAAc,EAAE,KAAK,EAAE,oBAAoB,GAAG,aAAa,CA4BrF;AAED,eAAe,WAAW,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { Schema } from "../../Schema.js";
|
|
2
|
+
import { KeyValidationDetails } from "../ValidateEngine.js";
|
|
3
|
+
declare function handleMissingKey(schema: Schema, input: KeyValidationDetails): any;
|
|
4
|
+
export default handleMissingKey;
|
|
5
|
+
//# sourceMappingURL=handleMissingKey.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"handleMissingKey.d.ts","sourceRoot":"","sources":["../../../src/engine/methods/handleMissingKey.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAEzC,OAAO,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAE5D,iBAAS,gBAAgB,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,oBAAoB,OAmBpE;AAED,eAAe,gBAAgB,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { SchemaDefinition } from "../../types/common.js";
|
|
2
|
+
import ValidnoResult from "../ValidnoResult.js";
|
|
3
|
+
import ValidateEngine from "../ValidateEngine.js";
|
|
4
|
+
export interface HandleMissingKeyValidationParams {
|
|
5
|
+
results: ValidnoResult;
|
|
6
|
+
key: string;
|
|
7
|
+
nestedKey: string;
|
|
8
|
+
data: any;
|
|
9
|
+
reqs: SchemaDefinition;
|
|
10
|
+
missedCheck: boolean[];
|
|
11
|
+
}
|
|
12
|
+
declare function handleMissingKeyValidation(this: ValidateEngine, params: HandleMissingKeyValidationParams): ValidnoResult;
|
|
13
|
+
export default handleMissingKeyValidation;
|
|
14
|
+
//# sourceMappingURL=handleMissingKeyValidation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"handleMissingKeyValidation.d.ts","sourceRoot":"","sources":["../../../src/engine/methods/handleMissingKeyValidation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,aAAa,MAAM,qBAAqB,CAAC;AAChD,OAAO,cAAc,MAAM,sBAAsB,CAAC;AAElD,MAAM,WAAW,gCAAgC;IAC7C,OAAO,EAAE,aAAa,CAAC;IACvB,GAAG,EAAE,MAAM,CAAC;IACZ,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,GAAG,CAAC;IACV,IAAI,EAAE,gBAAgB,CAAC;IACvB,WAAW,EAAE,OAAO,EAAE,CAAC;CAC1B;AAED,iBAAS,0BAA0B,CAC/B,IAAI,EAAE,cAAc,EACpB,MAAM,EAAE,gCAAgC,iBAU3C;AAED,eAAe,0BAA0B,CAAC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import ValidateEngine, { KeyValidationDetails } from "../ValidateEngine.js";
|
|
2
|
+
declare function handleNestedKey(this: ValidateEngine, input: KeyValidationDetails): import("../ValidnoResult.js").default;
|
|
3
|
+
export default handleNestedKey;
|
|
4
|
+
//# sourceMappingURL=handleNestedKey.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"handleNestedKey.d.ts","sourceRoot":"","sources":["../../../src/engine/methods/handleNestedKey.ts"],"names":[],"mappings":"AAAA,OAAO,cAAc,EAAE,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAE5E,iBAAS,eAAe,CAAC,IAAI,EAAE,cAAc,EAAE,KAAK,EAAE,oBAAoB,yCAyBzE;AAED,eAAe,eAAe,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import ValidnoResult from "../ValidnoResult.js";
|
|
2
|
+
import ValidateEngine from "../ValidateEngine.js";
|
|
3
|
+
declare function validate(this: ValidateEngine, data: any, validationKeys?: string | string[]): ValidnoResult;
|
|
4
|
+
export default validate;
|
|
5
|
+
//# sourceMappingURL=validate.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validate.d.ts","sourceRoot":"","sources":["../../../src/engine/methods/validate.ts"],"names":[],"mappings":"AACA,OAAO,aAAa,MAAM,qBAAqB,CAAA;AAC/C,OAAO,cAAwC,MAAM,sBAAsB,CAAA;AAE3E,iBAAS,QAAQ,CACb,IAAI,EAAE,cAAc,EACpB,IAAI,EAAE,GAAG,EACT,cAAc,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,GACnC,aAAa,CAaf;AAED,eAAe,QAAQ,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import ValidnoResult from "../ValidnoResult.js";
|
|
2
|
+
import { SchemaDefinition } from "../../types/common.js";
|
|
3
|
+
export interface ValidateRulesInput {
|
|
4
|
+
results: ValidnoResult;
|
|
5
|
+
nestedKey: string;
|
|
6
|
+
value: any;
|
|
7
|
+
reqs: SchemaDefinition;
|
|
8
|
+
data: any;
|
|
9
|
+
rulesChecked: boolean[];
|
|
10
|
+
}
|
|
11
|
+
export declare type Rule = Record<string, any>;
|
|
12
|
+
export declare const rulesParams: {
|
|
13
|
+
lengthMin: {
|
|
14
|
+
allowedTypes: StringConstructor[];
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
declare function validateRules(input: ValidateRulesInput): void;
|
|
18
|
+
export default validateRules;
|
|
19
|
+
//# sourceMappingURL=validateRules.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validateRules.d.ts","sourceRoot":"","sources":["../../../src/engine/methods/validateRules.ts"],"names":[],"mappings":"AAEA,OAAO,aAAa,MAAM,qBAAqB,CAAC;AAGhD,OAAO,EAAe,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAEtE,MAAM,WAAW,kBAAkB;IAC/B,OAAO,EAAE,aAAa,CAAC;IACvB,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,GAAG,CAAC;IACX,IAAI,EAAE,gBAAgB,CAAC;IACvB,IAAI,EAAE,GAAG,CAAC;IACV,YAAY,EAAE,OAAO,EAAE,CAAA;CAC1B;AAED,oBAAY,IAAI,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;AAItC,eAAO,MAAM,WAAW;;;;CAIvB,CAAA;AAiND,iBAAS,aAAa,CAAC,KAAK,EAAE,kBAAkB,QAe/C;AAED,eAAe,aAAa,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { SchemaDefinition } from "../../types/common.js";
|
|
2
|
+
import ValidnoResult from "../ValidnoResult.js";
|
|
3
|
+
export interface ValidateValueInput {
|
|
4
|
+
results: ValidnoResult;
|
|
5
|
+
key: string;
|
|
6
|
+
value: any;
|
|
7
|
+
reqs: SchemaDefinition;
|
|
8
|
+
nestedKey: string;
|
|
9
|
+
typeChecked: boolean[];
|
|
10
|
+
}
|
|
11
|
+
declare function validateType(input: ValidateValueInput): void;
|
|
12
|
+
export default validateType;
|
|
13
|
+
//# sourceMappingURL=validateType.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validateType.d.ts","sourceRoot":"","sources":["../../../src/engine/methods/validateType.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAe,MAAM,uBAAuB,CAAC;AACtE,OAAO,aAAa,MAAM,qBAAqB,CAAC;AAiLhD,MAAM,WAAW,kBAAkB;IAC/B,OAAO,EAAE,aAAa,CAAC;IACvB,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,GAAG,CAAC;IACX,IAAI,EAAE,gBAAgB,CAAC;IACvB,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,OAAO,EAAE,CAAA;CACzB;AAED,iBAAS,YAAY,CAAC,KAAK,EAAE,kBAAkB,QAU9C;AAED,eAAe,YAAY,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { Schema } from "./Schema.js";
|
|
2
|
+
import ValidnoResult from "./engine/ValidnoResult.js";
|
|
3
|
+
export declare const validations: {
|
|
4
|
+
isString(value: any): boolean;
|
|
5
|
+
isNumber(value: any): boolean;
|
|
6
|
+
isArray(value: any): boolean;
|
|
7
|
+
isObject(value: any): boolean;
|
|
8
|
+
isDate(value: any): boolean;
|
|
9
|
+
isRegex(value: any): boolean;
|
|
10
|
+
isBoolean(value: any): boolean;
|
|
11
|
+
isNull(value: any): boolean;
|
|
12
|
+
isUndefined(value: any): boolean;
|
|
13
|
+
isNullOrUndefined(value: any): boolean;
|
|
14
|
+
isEmail(value: string): boolean;
|
|
15
|
+
isDateYYYYMMDD(value: string): boolean;
|
|
16
|
+
isHex(value: string): boolean;
|
|
17
|
+
lengthIs(value: string | any[], length: number): boolean;
|
|
18
|
+
lengthNot(value: string | any[], length: number): boolean;
|
|
19
|
+
lengthMin(value: string | any[], min: number): boolean;
|
|
20
|
+
lengthMax(value: string | any[], max: number): boolean;
|
|
21
|
+
isNumberGte(value: any, gte: number): boolean;
|
|
22
|
+
isNumberGt(value: any, gt: number): boolean;
|
|
23
|
+
isNumberLte(value: any, lte: number): boolean;
|
|
24
|
+
isNumberLt(value: any, lt: number): boolean;
|
|
25
|
+
isDateGte(date1: any, date2: Date): boolean;
|
|
26
|
+
isDateGt(date1: any, date2: Date): boolean;
|
|
27
|
+
isDateLte(date1: any, date2: Date): boolean;
|
|
28
|
+
isDateLt(date1: any, date2: Date): boolean;
|
|
29
|
+
hasKey(obj: object, key: string): boolean;
|
|
30
|
+
is(value: any, compareTo: any): boolean;
|
|
31
|
+
not(value: any, not: any): boolean;
|
|
32
|
+
regexTested(value: string, regexp: RegExp): boolean;
|
|
33
|
+
readonly gt: (value: any, gt: number) => boolean;
|
|
34
|
+
readonly gte: (value: any, gte: number) => boolean;
|
|
35
|
+
readonly lte: (value: any, lte: number) => boolean;
|
|
36
|
+
readonly lt: (value: any, lt: number) => boolean;
|
|
37
|
+
readonly eq: (value: any, compareTo: any) => boolean;
|
|
38
|
+
readonly isNot: (value: any, not: any) => boolean;
|
|
39
|
+
readonly ne: (value: any, not: any) => boolean;
|
|
40
|
+
readonly neq: (value: any, not: any) => boolean;
|
|
41
|
+
readonly regex: (value: string, regexp: RegExp) => boolean;
|
|
42
|
+
readonly regexp: (value: string, regexp: RegExp) => boolean;
|
|
43
|
+
readonly test: (value: string, regexp: RegExp) => boolean;
|
|
44
|
+
};
|
|
45
|
+
export { ValidnoResult, Schema };
|
|
46
|
+
export default Schema;
|
|
47
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAErC,OAAO,aAAa,MAAM,2BAA2B,CAAC;AAGtD,eAAO,MAAM,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAAe,CAAA;AACvC,OAAO,EAAE,aAAa,EAAE,MAAM,EAAE,CAAA;AAGhC,eAAe,MAAM,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export interface SchemaDefinition {
|
|
2
|
+
[key: string]: FieldSchema | SchemaDefinition;
|
|
3
|
+
}
|
|
4
|
+
export interface FieldSchema {
|
|
5
|
+
required?: boolean;
|
|
6
|
+
type: unknown;
|
|
7
|
+
eachType?: unknown;
|
|
8
|
+
rules?: Record<string, unknown>;
|
|
9
|
+
title?: string;
|
|
10
|
+
customMessage?: (callbackInput: CustomMessageDetails) => string;
|
|
11
|
+
}
|
|
12
|
+
export interface CustomMessageDetails {
|
|
13
|
+
keyword: string;
|
|
14
|
+
value: unknown;
|
|
15
|
+
key: string;
|
|
16
|
+
title: string;
|
|
17
|
+
reqs: FieldSchema;
|
|
18
|
+
schema: SchemaDefinition;
|
|
19
|
+
rules?: Record<string, unknown>;
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=common.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../../src/types/common.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,gBAAgB;IAC7B,CAAC,GAAG,EAAE,MAAM,GAAG,WAAW,GAAG,gBAAgB,CAAA;CAChD;AAED,MAAM,WAAW,WAAW;IACxB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,IAAI,EAAE,OAAO,CAAC;IACd,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAChC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,aAAa,CAAC,EAAE,CAAC,aAAa,EAAE,oBAAoB,KAAK,MAAM,CAAA;CAClE;AAED,MAAM,WAAW,oBAAoB;IACjC,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,OAAO,CAAC;IACf,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,WAAW,CAAC;IAClB,MAAM,EAAE,gBAAgB,CAAC;IACzB,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CAClC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
interface ErrorUtils {
|
|
2
|
+
getMissingError: (key?: string) => string;
|
|
3
|
+
getErrorDetails: (key: string, expectedType: any, receivedValue: any) => string;
|
|
4
|
+
joinErrors: (errorsArr: string[], separator?: string) => string;
|
|
5
|
+
}
|
|
6
|
+
declare class ErrorUtility implements ErrorUtils {
|
|
7
|
+
getMissingError(key?: string): string;
|
|
8
|
+
getErrorDetails(key: string, expectedType: any, receivedValue: any): string;
|
|
9
|
+
joinErrors(errorsArr: string[], separator?: string): string;
|
|
10
|
+
private getTypeString;
|
|
11
|
+
private getExpectedTypeString;
|
|
12
|
+
}
|
|
13
|
+
declare const errors: ErrorUtility;
|
|
14
|
+
export default errors;
|
|
15
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/utils/errors.ts"],"names":[],"mappings":"AAAA,UAAU,UAAU;IAClB,eAAe,EAAE,CAAC,GAAG,CAAC,EAAE,MAAM,KAAK,MAAM,CAAC;IAC1C,eAAe,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,YAAY,EAAE,GAAG,EAAE,aAAa,EAAE,GAAG,KAAK,MAAM,CAAC;IAChF,UAAU,EAAE,CAAC,SAAS,EAAE,MAAM,EAAE,EAAE,SAAS,CAAC,EAAE,MAAM,KAAK,MAAM,CAAC;CACjE;AAED,cAAM,YAAa,YAAW,UAAU;IAMtC,eAAe,CAAC,GAAG,GAAE,MAAa,GAAG,MAAM;IAW3C,eAAe,CAAC,GAAG,EAAE,MAAM,EAAE,YAAY,EAAE,GAAG,EAAE,aAAa,EAAE,GAAG,GAAG,MAAM;IAiB3E,UAAU,CAAC,SAAS,EAAE,MAAM,EAAE,EAAE,SAAS,GAAE,MAAa,GAAG,MAAM;IAQjE,OAAO,CAAC,aAAa;IAWrB,OAAO,CAAC,qBAAqB;CAG9B;AAED,QAAA,MAAM,MAAM,cAAqB,CAAC;AAClC,eAAe,MAAM,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { KeyValidationDetails } from "../engine/ValidateEngine.js";
|
|
2
|
+
import { SchemaDefinition } from "../types/common.js";
|
|
3
|
+
interface HelperUtils {
|
|
4
|
+
checkIsNested: (obj: Record<string, any>) => boolean;
|
|
5
|
+
checkNestedIsMissing: (reqs: SchemaDefinition, data: any) => boolean;
|
|
6
|
+
areKeysLimited: (onlyKeys: string[] | string) => boolean;
|
|
7
|
+
needValidation: (key: string, hasLimits: boolean, onlyKeys?: string | string[]) => boolean;
|
|
8
|
+
hasMissing: (input: KeyValidationDetails) => boolean;
|
|
9
|
+
compareArrs: (v1: unknown[], v2: unknown[]) => boolean;
|
|
10
|
+
compareObjs: (obj1: object, obj2: object) => boolean;
|
|
11
|
+
}
|
|
12
|
+
declare class HelperUtility implements HelperUtils {
|
|
13
|
+
checkIsNested(obj: Record<string, any>): boolean;
|
|
14
|
+
checkNestedIsMissing(reqs: SchemaDefinition, data: any): boolean;
|
|
15
|
+
areKeysLimited(onlyKeys?: string[] | string): boolean;
|
|
16
|
+
needValidation(key: string, hasLimits: boolean, onlyKeys?: string | string[]): boolean;
|
|
17
|
+
hasMissing(input: KeyValidationDetails): boolean;
|
|
18
|
+
compareArrs(v1: unknown[], v2: unknown[]): boolean;
|
|
19
|
+
compareObjs(obj1: object, obj2: object): boolean;
|
|
20
|
+
private deepEqual;
|
|
21
|
+
}
|
|
22
|
+
declare const helpers: HelperUtility;
|
|
23
|
+
export default helpers;
|
|
24
|
+
//# sourceMappingURL=helpers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../src/utils/helpers.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;AACnE,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAEtD,UAAU,WAAW;IAC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;IAWhD,OAAO,CAAC,SAAS;CA2BlB;AAED,QAAA,MAAM,OAAO,eAAsB,CAAC;AACpC,eAAe,OAAO,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"isObjectId.d.ts","sourceRoot":"","sources":["../../src/utils/isObjectId.ts"],"names":[],"mappings":"AAAA,QAAA,MAAM,UAAU,UAAW,OAAO,gBAAgB,OAAO,YAKxD,CAAA;AAED,eAAe,UAAU,CAAA"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export interface TypeValidationResult {
|
|
2
|
+
key: string;
|
|
3
|
+
passed: boolean;
|
|
4
|
+
details?: string;
|
|
5
|
+
}
|
|
6
|
+
interface TypeValidationUtils {
|
|
7
|
+
getResult: (key: string, passed: boolean, details?: string) => TypeValidationResult;
|
|
8
|
+
}
|
|
9
|
+
declare class TypeValidationUtility implements TypeValidationUtils {
|
|
10
|
+
getResult(key: string, passed: boolean, details?: string): TypeValidationResult;
|
|
11
|
+
}
|
|
12
|
+
declare const validateType: TypeValidationUtility;
|
|
13
|
+
export default validateType;
|
|
14
|
+
//# sourceMappingURL=validateType.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validateType.d.ts","sourceRoot":"","sources":["../../src/utils/validateType.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,oBAAoB;IACnC,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,OAAO,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,UAAU,mBAAmB;IAC3B,SAAS,EAAE,CACT,GAAG,EAAE,MAAM,EACX,MAAM,EAAE,OAAO,EACf,OAAO,CAAC,EAAE,MAAM,KACb,oBAAoB,CAAC;CAC3B;AAED,cAAM,qBAAsB,YAAW,mBAAmB;IAQxD,SAAS,CACP,GAAG,EAAE,MAAM,EACX,MAAM,EAAE,OAAO,EACf,OAAO,GAAE,MAA6B,GACrC,oBAAoB;CAOxB;AAED,QAAA,MAAM,YAAY,uBAA8B,CAAC;AACjD,eAAe,YAAY,CAAC"}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
interface ValidationUtils {
|
|
2
|
+
isString: (value: any) => boolean;
|
|
3
|
+
isNumber: (value: any) => boolean;
|
|
4
|
+
isArray: (value: any) => boolean;
|
|
5
|
+
isObject: (value: any) => boolean;
|
|
6
|
+
isDate: (value: any) => boolean;
|
|
7
|
+
isRegex: (value: any) => boolean;
|
|
8
|
+
isBoolean: (value: any) => boolean;
|
|
9
|
+
isNull: (value: any) => boolean;
|
|
10
|
+
isUndefined: (value: any) => boolean;
|
|
11
|
+
isNullOrUndefined: (value: any) => boolean;
|
|
12
|
+
isEmail: (value: string) => boolean;
|
|
13
|
+
isDateYYYYMMDD: (value: string) => boolean;
|
|
14
|
+
isHex: (value: string) => boolean;
|
|
15
|
+
lengthIs: (value: string | any[], length: number) => boolean;
|
|
16
|
+
lengthNot: (value: string | any[], length: number) => boolean;
|
|
17
|
+
lengthMin: (value: string | any[], min: number) => boolean;
|
|
18
|
+
lengthMax: (value: string | any[], max: number) => boolean;
|
|
19
|
+
isNumberGte: (value: any, gte: number) => boolean;
|
|
20
|
+
isNumberGt: (value: any, gt: number) => boolean;
|
|
21
|
+
isNumberLte: (value: any, lte: number) => boolean;
|
|
22
|
+
isNumberLt: (value: any, lt: number) => boolean;
|
|
23
|
+
isDateGte: (date1: any, date2: Date) => boolean;
|
|
24
|
+
isDateGt: (date1: any, date2: Date) => boolean;
|
|
25
|
+
isDateLte: (date1: any, date2: Date) => boolean;
|
|
26
|
+
isDateLt: (date1: any, date2: Date) => boolean;
|
|
27
|
+
hasKey: (obj: object, key: string) => boolean;
|
|
28
|
+
is: (value: any, compareTo: any) => boolean;
|
|
29
|
+
not: (value: any, not: any) => boolean;
|
|
30
|
+
regexTested: (value: string, regexp: RegExp) => boolean;
|
|
31
|
+
gt: (value: any, gt: number) => boolean;
|
|
32
|
+
gte: (value: any, gte: number) => boolean;
|
|
33
|
+
lte: (value: any, lte: number) => boolean;
|
|
34
|
+
lt: (value: any, lt: number) => boolean;
|
|
35
|
+
eq: (value: any, compareTo: any) => boolean;
|
|
36
|
+
isNot: (value: any, not: any) => boolean;
|
|
37
|
+
ne: (value: any, not: any) => boolean;
|
|
38
|
+
neq: (value: any, not: any) => boolean;
|
|
39
|
+
regex: (value: string, regexp: RegExp) => boolean;
|
|
40
|
+
regexp: (value: string, regexp: RegExp) => boolean;
|
|
41
|
+
test: (value: string, regexp: RegExp) => boolean;
|
|
42
|
+
}
|
|
43
|
+
declare class ValidationUtility implements ValidationUtils {
|
|
44
|
+
isString(value: any): boolean;
|
|
45
|
+
isNumber(value: any): boolean;
|
|
46
|
+
isArray(value: any): boolean;
|
|
47
|
+
isObject(value: any): boolean;
|
|
48
|
+
isDate(value: any): boolean;
|
|
49
|
+
isRegex(value: any): boolean;
|
|
50
|
+
isBoolean(value: any): boolean;
|
|
51
|
+
isNull(value: any): boolean;
|
|
52
|
+
isUndefined(value: any): boolean;
|
|
53
|
+
isNullOrUndefined(value: any): boolean;
|
|
54
|
+
isEmail(value: string): boolean;
|
|
55
|
+
isDateYYYYMMDD(value: string): boolean;
|
|
56
|
+
isHex(value: string): boolean;
|
|
57
|
+
lengthIs(value: string | any[], length: number): boolean;
|
|
58
|
+
lengthNot(value: string | any[], length: number): boolean;
|
|
59
|
+
lengthMin(value: string | any[], min: number): boolean;
|
|
60
|
+
lengthMax(value: string | any[], max: number): boolean;
|
|
61
|
+
isNumberGte(value: any, gte: number): boolean;
|
|
62
|
+
isNumberGt(value: any, gt: number): boolean;
|
|
63
|
+
isNumberLte(value: any, lte: number): boolean;
|
|
64
|
+
isNumberLt(value: any, lt: number): boolean;
|
|
65
|
+
isDateGte(date1: any, date2: Date): boolean;
|
|
66
|
+
isDateGt(date1: any, date2: Date): boolean;
|
|
67
|
+
isDateLte(date1: any, date2: Date): boolean;
|
|
68
|
+
isDateLt(date1: any, date2: Date): boolean;
|
|
69
|
+
hasKey(obj: object, key: string): boolean;
|
|
70
|
+
is(value: any, compareTo: any): boolean;
|
|
71
|
+
not(value: any, not: any): boolean;
|
|
72
|
+
regexTested(value: string, regexp: RegExp): boolean;
|
|
73
|
+
get gt(): (value: any, gt: number) => boolean;
|
|
74
|
+
get gte(): (value: any, gte: number) => boolean;
|
|
75
|
+
get lte(): (value: any, lte: number) => boolean;
|
|
76
|
+
get lt(): (value: any, lt: number) => boolean;
|
|
77
|
+
get eq(): (value: any, compareTo: any) => boolean;
|
|
78
|
+
get isNot(): (value: any, not: any) => boolean;
|
|
79
|
+
get ne(): (value: any, not: any) => boolean;
|
|
80
|
+
get neq(): (value: any, not: any) => boolean;
|
|
81
|
+
get regex(): (value: string, regexp: RegExp) => boolean;
|
|
82
|
+
get regexp(): (value: string, regexp: RegExp) => boolean;
|
|
83
|
+
get test(): (value: string, regexp: RegExp) => boolean;
|
|
84
|
+
}
|
|
85
|
+
declare const validations: ValidationUtility;
|
|
86
|
+
export default validations;
|
|
87
|
+
//# sourceMappingURL=validations.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validations.d.ts","sourceRoot":"","sources":["../../src/utils/validations.ts"],"names":[],"mappings":"AAEA,UAAU,eAAe;IAEvB,QAAQ,EAAE,CAAC,KAAK,EAAE,GAAG,KAAK,OAAO,CAAC;IAClC,QAAQ,EAAE,CAAC,KAAK,EAAE,GAAG,KAAK,OAAO,CAAC;IAClC,OAAO,EAAE,CAAC,KAAK,EAAE,GAAG,KAAK,OAAO,CAAC;IACjC,QAAQ,EAAE,CAAC,KAAK,EAAE,GAAG,KAAK,OAAO,CAAC;IAClC,MAAM,EAAE,CAAC,KAAK,EAAE,GAAG,KAAK,OAAO,CAAC;IAChC,OAAO,EAAE,CAAC,KAAK,EAAE,GAAG,KAAK,OAAO,CAAC;IACjC,SAAS,EAAE,CAAC,KAAK,EAAE,GAAG,KAAK,OAAO,CAAC;IACnC,MAAM,EAAE,CAAC,KAAK,EAA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CACxC;AAED,QAAA,MAAM,WAAW,mBAA0B,CAAC;AAC5C,eAAe,WAAW,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,18 +1,30 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "validno",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"description": "A lightweight TypeScript validation library for runtime data validation. Used as part of Kodzero API framework.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"type": "module",
|
|
6
8
|
"scripts": {
|
|
7
9
|
"tsc": "tsc -b src/",
|
|
8
10
|
"tsc-watch": "tsc --b --watch src/",
|
|
9
11
|
"tscw": "tsc --b --watch src/",
|
|
10
12
|
"dev": "nodemon dist/dev.js",
|
|
11
|
-
"test": "node --experimental-vm-modules node_modules/jest/bin/jest.js"
|
|
13
|
+
"test": "node --experimental-vm-modules node_modules/jest/bin/jest.js",
|
|
14
|
+
"prepublishOnly": "npm run tsc"
|
|
15
|
+
},
|
|
16
|
+
"files": [
|
|
17
|
+
"dist/**/*",
|
|
18
|
+
"README.md"
|
|
19
|
+
],
|
|
20
|
+
"exports": {
|
|
21
|
+
".": {
|
|
22
|
+
"import": "./dist/index.js",
|
|
23
|
+
"types": "./dist/index.d.ts"
|
|
24
|
+
}
|
|
12
25
|
},
|
|
13
26
|
"author": "lesha2r",
|
|
14
27
|
"license": "ISC",
|
|
15
|
-
"type": "module",
|
|
16
28
|
"dependencies": {
|
|
17
29
|
"ts-node": "^10.9.1",
|
|
18
30
|
"ts-node-dev": "^2.0.0"
|
package/nodemon.json
DELETED