custom-class-validator-tools 1.0.15 → 1.0.18
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/index.d.ts +46 -0
- package/dist/index.js +64 -0
- package/dist/src/decorator/transform/any-to-bigint.decorator.d.ts +2 -0
- package/dist/src/decorator/transform/any-to-bigint.decorator.js +40 -0
- package/dist/src/decorator/transform/any-to-number.decorator.d.ts +2 -0
- package/dist/src/decorator/transform/any-to-number.decorator.js +43 -0
- package/dist/src/decorator/transform/any-to-string.decorator.d.ts +2 -0
- package/dist/src/decorator/transform/any-to-string.decorator.js +15 -0
- package/dist/src/decorator/transform/number-to-boolean.decorator.d.ts +2 -0
- package/dist/src/decorator/transform/number-to-boolean.decorator.js +22 -0
- package/dist/src/decorator/transform/string-to-boolean.decorator.d.ts +2 -0
- package/dist/src/decorator/transform/string-to-boolean.decorator.js +24 -0
- package/dist/src/decorator/validate/function/string-validator.function.d.ts +1 -0
- package/dist/src/decorator/validate/function/string-validator.function.js +13 -0
- package/dist/src/decorator/validate/is-not-empty-bigint-string.decorator.d.ts +2 -0
- package/dist/src/decorator/validate/is-not-empty-bigint-string.decorator.js +49 -0
- package/dist/src/decorator/validate/is-not-empty-bigint.decorator.d.ts +2 -0
- package/dist/src/decorator/validate/is-not-empty-bigint.decorator.js +23 -0
- package/dist/src/decorator/validate/is-not-empty-boolean-string.decorator.d.ts +2 -0
- package/dist/src/decorator/validate/is-not-empty-boolean-string.decorator.js +23 -0
- package/dist/src/decorator/validate/is-not-empty-boolean.decorator.d.ts +2 -0
- package/dist/src/decorator/validate/is-not-empty-boolean.decorator.js +23 -0
- package/dist/src/decorator/validate/is-not-empty-number-string.decorator.d.ts +4 -0
- package/dist/src/decorator/validate/is-not-empty-number-string.decorator.js +54 -0
- package/dist/src/decorator/validate/is-not-empty-number.decorator.d.ts +4 -0
- package/dist/src/decorator/validate/is-not-empty-number.decorator.js +51 -0
- package/dist/src/decorator/validate/is-not-empty-sql-date-string.decorator.d.ts +2 -0
- package/dist/src/decorator/validate/is-not-empty-sql-date-string.decorator.js +30 -0
- package/dist/src/decorator/validate/is-not-empty-sql-date-time-string.decorator.d.ts +2 -0
- package/dist/src/decorator/validate/is-not-empty-sql-date-time-string.decorator.js +30 -0
- package/dist/src/decorator/validate/is-not-empty-sql-time-string.decorator.d.ts +4 -0
- package/dist/src/decorator/validate/is-not-empty-sql-time-string.decorator.js +51 -0
- package/dist/src/decorator/validate/is-not-empty-string.decorator.d.ts +4 -0
- package/dist/src/decorator/validate/is-not-empty-string.decorator.js +24 -0
- package/dist/src/decorator/validate/is-nullable-bigint.decorator.d.ts +2 -0
- package/dist/src/decorator/validate/is-nullable-bigint.decorator.js +24 -0
- package/dist/src/decorator/validate/is-nullable-boolean-string.decorator.d.ts +2 -0
- package/dist/src/decorator/validate/is-nullable-boolean-string.decorator.js +24 -0
- package/dist/src/decorator/validate/is-nullable-boolean.decorator.d.ts +2 -0
- package/dist/src/decorator/validate/is-nullable-boolean.decorator.js +24 -0
- package/dist/src/decorator/validate/is-nullable-number-string.decorator.d.ts +4 -0
- package/dist/src/decorator/validate/is-nullable-number-string.decorator.js +54 -0
- package/dist/src/decorator/validate/is-nullable-number.decorator.d.ts +4 -0
- package/dist/src/decorator/validate/is-nullable-number.decorator.js +53 -0
- package/dist/src/decorator/validate/is-nullable-sql-date-string.decorator.d.ts +2 -0
- package/dist/src/decorator/validate/is-nullable-sql-date-string.decorator.js +30 -0
- package/dist/src/decorator/validate/is-nullable-sql-date-time-string.decorator.d.ts +2 -0
- package/dist/src/decorator/validate/is-nullable-sql-date-time-string.decorator.js +30 -0
- package/dist/src/decorator/validate/is-nullable-sql-time-string.decorator.d.ts +4 -0
- package/dist/src/decorator/validate/is-nullable-sql-time-string.decorator.js +53 -0
- package/dist/src/decorator/validate/is-nullable-string.decorator.d.ts +4 -0
- package/dist/src/decorator/validate/is-nullable-string.decorator.js +26 -0
- package/dist/src/decorator/validate/is-nullable.decorator.d.ts +1 -0
- package/dist/src/decorator/validate/is-nullable.decorator.js +11 -0
- package/dist/src/decorator/validate/is-optional-bigint.decorator.d.ts +2 -0
- package/dist/src/decorator/validate/is-optional-bigint.decorator.js +24 -0
- package/dist/src/decorator/validate/is-optional-boolean-string.decorator.d.ts +2 -0
- package/dist/src/decorator/validate/is-optional-boolean-string.decorator.js +24 -0
- package/dist/src/decorator/validate/is-optional-boolean.decorator.d.ts +2 -0
- package/dist/src/decorator/validate/is-optional-boolean.decorator.js +24 -0
- package/dist/src/decorator/validate/is-optional-number-string.decorator.d.ts +4 -0
- package/dist/src/decorator/validate/is-optional-number-string.decorator.js +53 -0
- package/dist/src/decorator/validate/is-optional-number.decorator.d.ts +4 -0
- package/dist/src/decorator/validate/is-optional-number.decorator.js +52 -0
- package/dist/src/decorator/validate/is-optional-sql-date-string.decorator.d.ts +2 -0
- package/dist/src/decorator/validate/is-optional-sql-date-string.decorator.js +30 -0
- package/dist/src/decorator/validate/is-optional-sql-date-time-string.decorator.d.ts +2 -0
- package/dist/src/decorator/validate/is-optional-sql-date-time-string.decorator.js +30 -0
- package/dist/src/decorator/validate/is-optional-sql-time-string.decorator.d.ts +4 -0
- package/dist/src/decorator/validate/is-optional-sql-time-string.decorator.js +56 -0
- package/dist/src/decorator/validate/is-optional-string.decorator.d.ts +4 -0
- package/dist/src/decorator/validate/is-optional-string.decorator.js +26 -0
- package/dist/src/decorator/validate/is-undefinable-bigint.decorator.d.ts +2 -0
- package/dist/src/decorator/validate/is-undefinable-bigint.decorator.js +24 -0
- package/dist/src/decorator/validate/is-undefinable-boolean-string.decorator.d.ts +2 -0
- package/dist/src/decorator/validate/is-undefinable-boolean-string.decorator.js +24 -0
- package/dist/src/decorator/validate/is-undefinable-boolean.decorator.d.ts +2 -0
- package/dist/src/decorator/validate/is-undefinable-boolean.decorator.js +24 -0
- package/dist/src/decorator/validate/is-undefinable-number-string.decorator.d.ts +4 -0
- package/dist/src/decorator/validate/is-undefinable-number-string.decorator.js +54 -0
- package/dist/src/decorator/validate/is-undefinable-number.decorator.d.ts +4 -0
- package/dist/src/decorator/validate/is-undefinable-number.decorator.js +53 -0
- package/dist/src/decorator/validate/is-undefinable-sql-date-string.decorator.d.ts +2 -0
- package/dist/src/decorator/validate/is-undefinable-sql-date-string.decorator.js +30 -0
- package/dist/src/decorator/validate/is-undefinable-sql-date-time-string.decorator.d.ts +2 -0
- package/dist/src/decorator/validate/is-undefinable-sql-date-time-string.decorator.js +30 -0
- package/dist/src/decorator/validate/is-undefinable-sql-time.decorator.d.ts +4 -0
- package/dist/src/decorator/validate/is-undefinable-sql-time.decorator.js +57 -0
- package/dist/src/decorator/validate/is-undefinable-string.decorator.d.ts +4 -0
- package/dist/src/decorator/validate/is-undefinable-string.decorator.js +26 -0
- package/dist/src/decorator/validate/is-undefinable.decorator.d.ts +1 -0
- package/dist/src/decorator/validate/is-undefinable.decorator.js +11 -0
- package/dist/src/function/validate-with-header.decorators.d.ts +2 -0
- package/dist/src/function/validate-with-header.decorators.js +33 -0
- package/dist/src/util/is-boolean.d.ts +2 -0
- package/dist/src/util/is-boolean.js +11 -0
- package/dist/src/util/is-empty.d.ts +12 -0
- package/dist/src/util/is-empty.js +80 -0
- package/package.json +1 -1
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
export * from './src/decorator/validate/function/string-validator.function';
|
|
2
|
+
export * from './src/decorator/transform/any-to-bigint.decorator';
|
|
3
|
+
export * from './src/decorator/transform/any-to-number.decorator';
|
|
4
|
+
export * from './src/decorator/transform/any-to-string.decorator';
|
|
5
|
+
export * from './src/decorator/transform/number-to-boolean.decorator';
|
|
6
|
+
export * from './src/decorator/transform/string-to-boolean.decorator';
|
|
7
|
+
export * from './src/decorator/validate/is-not-empty-bigint-string.decorator';
|
|
8
|
+
export * from './src/decorator/validate/is-not-empty-bigint.decorator';
|
|
9
|
+
export * from './src/decorator/validate/is-not-empty-boolean-string.decorator';
|
|
10
|
+
export * from './src/decorator/validate/is-not-empty-boolean.decorator';
|
|
11
|
+
export * from './src/decorator/validate/is-not-empty-number-string.decorator';
|
|
12
|
+
export * from './src/decorator/validate/is-not-empty-number.decorator';
|
|
13
|
+
export * from './src/decorator/validate/is-not-empty-sql-date-string.decorator';
|
|
14
|
+
export * from './src/decorator/validate/is-not-empty-sql-date-time-string.decorator';
|
|
15
|
+
export * from './src/decorator/validate/is-not-empty-sql-time-string.decorator';
|
|
16
|
+
export * from './src/decorator/validate/is-not-empty-string.decorator';
|
|
17
|
+
export * from './src/decorator/validate/is-nullable-bigint.decorator';
|
|
18
|
+
export * from './src/decorator/validate/is-nullable-boolean-string.decorator';
|
|
19
|
+
export * from './src/decorator/validate/is-nullable-boolean.decorator';
|
|
20
|
+
export * from './src/decorator/validate/is-nullable-number-string.decorator';
|
|
21
|
+
export * from './src/decorator/validate/is-nullable-number.decorator';
|
|
22
|
+
export * from './src/decorator/validate/is-nullable-sql-date-string.decorator';
|
|
23
|
+
export * from './src/decorator/validate/is-nullable-sql-date-time-string.decorator';
|
|
24
|
+
export * from './src/decorator/validate/is-nullable-sql-time-string.decorator';
|
|
25
|
+
export * from './src/decorator/validate/is-nullable-string.decorator';
|
|
26
|
+
export * from './src/decorator/validate/is-nullable.decorator';
|
|
27
|
+
export * from './src/decorator/validate/is-optional-bigint.decorator';
|
|
28
|
+
export * from './src/decorator/validate/is-optional-boolean-string.decorator';
|
|
29
|
+
export * from './src/decorator/validate/is-optional-boolean.decorator';
|
|
30
|
+
export * from './src/decorator/validate/is-optional-number-string.decorator';
|
|
31
|
+
export * from './src/decorator/validate/is-optional-number.decorator';
|
|
32
|
+
export * from './src/decorator/validate/is-optional-sql-date-string.decorator';
|
|
33
|
+
export * from './src/decorator/validate/is-optional-sql-date-time-string.decorator';
|
|
34
|
+
export * from './src/decorator/validate/is-optional-sql-time-string.decorator';
|
|
35
|
+
export * from './src/decorator/validate/is-optional-string.decorator';
|
|
36
|
+
export * from './src/decorator/validate/is-undefinable-bigint.decorator';
|
|
37
|
+
export * from './src/decorator/validate/is-undefinable-boolean-string.decorator';
|
|
38
|
+
export * from './src/decorator/validate/is-undefinable-boolean.decorator';
|
|
39
|
+
export * from './src/decorator/validate/is-undefinable-number-string.decorator';
|
|
40
|
+
export * from './src/decorator/validate/is-undefinable-number.decorator';
|
|
41
|
+
export * from './src/decorator/validate/is-undefinable-sql-date-string.decorator';
|
|
42
|
+
export * from './src/decorator/validate/is-undefinable-sql-date-time-string.decorator';
|
|
43
|
+
export * from './src/decorator/validate/is-undefinable-sql-time.decorator';
|
|
44
|
+
export * from './src/decorator/validate/is-undefinable-string.decorator';
|
|
45
|
+
export * from './src/decorator/validate/is-undefinable.decorator';
|
|
46
|
+
export * from './src/function/validate-with-header.decorators';
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// created from ctix
|
|
3
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
4
|
+
if (k2 === undefined) k2 = k;
|
|
5
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
6
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
7
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
8
|
+
}
|
|
9
|
+
Object.defineProperty(o, k2, desc);
|
|
10
|
+
}) : (function(o, m, k, k2) {
|
|
11
|
+
if (k2 === undefined) k2 = k;
|
|
12
|
+
o[k2] = m[k];
|
|
13
|
+
}));
|
|
14
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
15
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
16
|
+
};
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
// created from ctix
|
|
19
|
+
__exportStar(require("./src/decorator/validate/function/string-validator.function"), exports);
|
|
20
|
+
__exportStar(require("./src/decorator/transform/any-to-bigint.decorator"), exports);
|
|
21
|
+
__exportStar(require("./src/decorator/transform/any-to-number.decorator"), exports);
|
|
22
|
+
__exportStar(require("./src/decorator/transform/any-to-string.decorator"), exports);
|
|
23
|
+
__exportStar(require("./src/decorator/transform/number-to-boolean.decorator"), exports);
|
|
24
|
+
__exportStar(require("./src/decorator/transform/string-to-boolean.decorator"), exports);
|
|
25
|
+
__exportStar(require("./src/decorator/validate/is-not-empty-bigint-string.decorator"), exports);
|
|
26
|
+
__exportStar(require("./src/decorator/validate/is-not-empty-bigint.decorator"), exports);
|
|
27
|
+
__exportStar(require("./src/decorator/validate/is-not-empty-boolean-string.decorator"), exports);
|
|
28
|
+
__exportStar(require("./src/decorator/validate/is-not-empty-boolean.decorator"), exports);
|
|
29
|
+
__exportStar(require("./src/decorator/validate/is-not-empty-number-string.decorator"), exports);
|
|
30
|
+
__exportStar(require("./src/decorator/validate/is-not-empty-number.decorator"), exports);
|
|
31
|
+
__exportStar(require("./src/decorator/validate/is-not-empty-sql-date-string.decorator"), exports);
|
|
32
|
+
__exportStar(require("./src/decorator/validate/is-not-empty-sql-date-time-string.decorator"), exports);
|
|
33
|
+
__exportStar(require("./src/decorator/validate/is-not-empty-sql-time-string.decorator"), exports);
|
|
34
|
+
__exportStar(require("./src/decorator/validate/is-not-empty-string.decorator"), exports);
|
|
35
|
+
__exportStar(require("./src/decorator/validate/is-nullable-bigint.decorator"), exports);
|
|
36
|
+
__exportStar(require("./src/decorator/validate/is-nullable-boolean-string.decorator"), exports);
|
|
37
|
+
__exportStar(require("./src/decorator/validate/is-nullable-boolean.decorator"), exports);
|
|
38
|
+
__exportStar(require("./src/decorator/validate/is-nullable-number-string.decorator"), exports);
|
|
39
|
+
__exportStar(require("./src/decorator/validate/is-nullable-number.decorator"), exports);
|
|
40
|
+
__exportStar(require("./src/decorator/validate/is-nullable-sql-date-string.decorator"), exports);
|
|
41
|
+
__exportStar(require("./src/decorator/validate/is-nullable-sql-date-time-string.decorator"), exports);
|
|
42
|
+
__exportStar(require("./src/decorator/validate/is-nullable-sql-time-string.decorator"), exports);
|
|
43
|
+
__exportStar(require("./src/decorator/validate/is-nullable-string.decorator"), exports);
|
|
44
|
+
__exportStar(require("./src/decorator/validate/is-nullable.decorator"), exports);
|
|
45
|
+
__exportStar(require("./src/decorator/validate/is-optional-bigint.decorator"), exports);
|
|
46
|
+
__exportStar(require("./src/decorator/validate/is-optional-boolean-string.decorator"), exports);
|
|
47
|
+
__exportStar(require("./src/decorator/validate/is-optional-boolean.decorator"), exports);
|
|
48
|
+
__exportStar(require("./src/decorator/validate/is-optional-number-string.decorator"), exports);
|
|
49
|
+
__exportStar(require("./src/decorator/validate/is-optional-number.decorator"), exports);
|
|
50
|
+
__exportStar(require("./src/decorator/validate/is-optional-sql-date-string.decorator"), exports);
|
|
51
|
+
__exportStar(require("./src/decorator/validate/is-optional-sql-date-time-string.decorator"), exports);
|
|
52
|
+
__exportStar(require("./src/decorator/validate/is-optional-sql-time-string.decorator"), exports);
|
|
53
|
+
__exportStar(require("./src/decorator/validate/is-optional-string.decorator"), exports);
|
|
54
|
+
__exportStar(require("./src/decorator/validate/is-undefinable-bigint.decorator"), exports);
|
|
55
|
+
__exportStar(require("./src/decorator/validate/is-undefinable-boolean-string.decorator"), exports);
|
|
56
|
+
__exportStar(require("./src/decorator/validate/is-undefinable-boolean.decorator"), exports);
|
|
57
|
+
__exportStar(require("./src/decorator/validate/is-undefinable-number-string.decorator"), exports);
|
|
58
|
+
__exportStar(require("./src/decorator/validate/is-undefinable-number.decorator"), exports);
|
|
59
|
+
__exportStar(require("./src/decorator/validate/is-undefinable-sql-date-string.decorator"), exports);
|
|
60
|
+
__exportStar(require("./src/decorator/validate/is-undefinable-sql-date-time-string.decorator"), exports);
|
|
61
|
+
__exportStar(require("./src/decorator/validate/is-undefinable-sql-time.decorator"), exports);
|
|
62
|
+
__exportStar(require("./src/decorator/validate/is-undefinable-string.decorator"), exports);
|
|
63
|
+
__exportStar(require("./src/decorator/validate/is-undefinable.decorator"), exports);
|
|
64
|
+
__exportStar(require("./src/function/validate-with-header.decorators"), exports);
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.AnyToBigInt = void 0;
|
|
27
|
+
const class_transformer_1 = require("class-transformer");
|
|
28
|
+
const FE = __importStar(require("fp-ts/Either"));
|
|
29
|
+
const FF = __importStar(require("fp-ts/function"));
|
|
30
|
+
const AnyToBigInt = () => {
|
|
31
|
+
const toPlain = (0, class_transformer_1.Transform)(({ value }) => value, { toPlainOnly: true });
|
|
32
|
+
const toClass = (target, key) => (0, class_transformer_1.Transform)(({ obj }) => {
|
|
33
|
+
return FF.pipe(FE.tryCatch(() => BigInt(obj[key]), () => obj[key]), FE.fold(left => left, right => right));
|
|
34
|
+
})(target, key);
|
|
35
|
+
return function (target, key) {
|
|
36
|
+
toPlain(target, key);
|
|
37
|
+
toClass(target, key);
|
|
38
|
+
};
|
|
39
|
+
};
|
|
40
|
+
exports.AnyToBigInt = AnyToBigInt;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.ToNumber = void 0;
|
|
27
|
+
const is_boolean_1 = require("../../util/is-boolean");
|
|
28
|
+
const class_transformer_1 = require("class-transformer");
|
|
29
|
+
const FF = __importStar(require("fp-ts/function"));
|
|
30
|
+
const FO = __importStar(require("fp-ts/Option"));
|
|
31
|
+
const ToNumber = () => {
|
|
32
|
+
const toPlain = (0, class_transformer_1.Transform)(({ value }) => value, { toPlainOnly: true });
|
|
33
|
+
const toClass = (target, key) => (0, class_transformer_1.Transform)(({ obj }) => {
|
|
34
|
+
return FF.pipe(Number(obj[key]), FO.fromPredicate(value => (0, is_boolean_1.isFalse)(Number.isNaN(value))), FO.fold(() => {
|
|
35
|
+
return obj[key];
|
|
36
|
+
}, right => right));
|
|
37
|
+
})(target, key);
|
|
38
|
+
return function (target, key) {
|
|
39
|
+
toPlain(target, key);
|
|
40
|
+
toClass(target, key);
|
|
41
|
+
};
|
|
42
|
+
};
|
|
43
|
+
exports.ToNumber = ToNumber;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AnyToString = void 0;
|
|
4
|
+
const class_transformer_1 = require("class-transformer");
|
|
5
|
+
const AnyToString = () => {
|
|
6
|
+
const toPlain = (0, class_transformer_1.Transform)(({ value }) => value, { toPlainOnly: true });
|
|
7
|
+
const toClass = (target, key) => (0, class_transformer_1.Transform)(({ obj }) => {
|
|
8
|
+
return `${obj[key]}`;
|
|
9
|
+
})(target, key);
|
|
10
|
+
return function (target, key) {
|
|
11
|
+
toPlain(target, key);
|
|
12
|
+
toClass(target, key);
|
|
13
|
+
};
|
|
14
|
+
};
|
|
15
|
+
exports.AnyToString = AnyToString;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.NumberToBoolean = void 0;
|
|
4
|
+
const class_transformer_1 = require("class-transformer");
|
|
5
|
+
const NumberToBoolean = () => {
|
|
6
|
+
const toPlain = (0, class_transformer_1.Transform)(({ value }) => value, { toPlainOnly: true });
|
|
7
|
+
const toClass = (target, key) => (0, class_transformer_1.Transform)(({ obj }) => {
|
|
8
|
+
switch (obj[key]) {
|
|
9
|
+
case 1:
|
|
10
|
+
return true;
|
|
11
|
+
case 0:
|
|
12
|
+
return false;
|
|
13
|
+
default:
|
|
14
|
+
return obj[key];
|
|
15
|
+
}
|
|
16
|
+
})(target, key);
|
|
17
|
+
return function (target, key) {
|
|
18
|
+
toPlain(target, key);
|
|
19
|
+
toClass(target, key);
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
exports.NumberToBoolean = NumberToBoolean;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.StringToBoolean = void 0;
|
|
4
|
+
const class_transformer_1 = require("class-transformer");
|
|
5
|
+
const StringToBoolean = () => {
|
|
6
|
+
const toPlain = (0, class_transformer_1.Transform)(({ value }) => value, { toPlainOnly: true });
|
|
7
|
+
const toClass = (target, key) => (0, class_transformer_1.Transform)(({ obj }) => {
|
|
8
|
+
switch (obj[key]) {
|
|
9
|
+
case true:
|
|
10
|
+
case 'true':
|
|
11
|
+
return true;
|
|
12
|
+
case false:
|
|
13
|
+
case 'false':
|
|
14
|
+
return false;
|
|
15
|
+
default:
|
|
16
|
+
return obj[key];
|
|
17
|
+
}
|
|
18
|
+
})(target, key);
|
|
19
|
+
return function (target, key) {
|
|
20
|
+
toPlain(target, key);
|
|
21
|
+
toClass(target, key);
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
exports.StringToBoolean = StringToBoolean;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function stringValidator(value: any, blank?: boolean): boolean;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.stringValidator = void 0;
|
|
4
|
+
function stringValidator(value, blank) {
|
|
5
|
+
switch (blank ?? false) {
|
|
6
|
+
case true:
|
|
7
|
+
return typeof value === 'string';
|
|
8
|
+
case false:
|
|
9
|
+
default:
|
|
10
|
+
return typeof value === 'string' && value.length > 0;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
exports.stringValidator = stringValidator;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.IsNotEmptyBigIntString = void 0;
|
|
27
|
+
const FE = __importStar(require("fp-ts/Either"));
|
|
28
|
+
const FF = __importStar(require("fp-ts/function"));
|
|
29
|
+
const FO = __importStar(require("fp-ts/Option"));
|
|
30
|
+
const class_validator_1 = require("class-validator");
|
|
31
|
+
function IsNotEmptyBigIntString(validationOptions) {
|
|
32
|
+
return function (object, propertyName) {
|
|
33
|
+
(0, class_validator_1.registerDecorator)({
|
|
34
|
+
name: 'IsNotEmptyBitIntString',
|
|
35
|
+
target: object.constructor,
|
|
36
|
+
propertyName: propertyName,
|
|
37
|
+
options: validationOptions,
|
|
38
|
+
validator: {
|
|
39
|
+
validate(value) {
|
|
40
|
+
return FF.pipe(value, FO.fromPredicate(refinement => typeof refinement === 'string' && refinement.length > 0), FO.map(notNullString => FF.pipe(FE.tryCatch(() => BigInt(notNullString), () => false), FE.fold(left => left, () => true))), FO.fold(() => false, right => right));
|
|
41
|
+
},
|
|
42
|
+
defaultMessage(validationArguments) {
|
|
43
|
+
return `${validationArguments?.property} should be bigint string`;
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
});
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
exports.IsNotEmptyBigIntString = IsNotEmptyBigIntString;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.IsNotEmptyBigInt = void 0;
|
|
4
|
+
const class_validator_1 = require("class-validator");
|
|
5
|
+
function IsNotEmptyBigInt(validationOptions) {
|
|
6
|
+
return function (object, propertyName) {
|
|
7
|
+
(0, class_validator_1.registerDecorator)({
|
|
8
|
+
name: 'IsNotEmptyBigInt',
|
|
9
|
+
target: object.constructor,
|
|
10
|
+
propertyName: propertyName,
|
|
11
|
+
options: validationOptions,
|
|
12
|
+
validator: {
|
|
13
|
+
validate(value) {
|
|
14
|
+
return typeof value === 'bigint';
|
|
15
|
+
},
|
|
16
|
+
defaultMessage(validationArguments) {
|
|
17
|
+
return `${validationArguments?.property} should be bigint`;
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
});
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
exports.IsNotEmptyBigInt = IsNotEmptyBigInt;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.IsNotEmptyBooleanString = void 0;
|
|
4
|
+
const class_validator_1 = require("class-validator");
|
|
5
|
+
function IsNotEmptyBooleanString(validationOptions) {
|
|
6
|
+
return function (object, propertyName) {
|
|
7
|
+
(0, class_validator_1.registerDecorator)({
|
|
8
|
+
name: 'INotEmptyBooleanString',
|
|
9
|
+
target: object.constructor,
|
|
10
|
+
propertyName: propertyName,
|
|
11
|
+
options: validationOptions,
|
|
12
|
+
validator: {
|
|
13
|
+
validate(value) {
|
|
14
|
+
return typeof value === 'string' && value.length > 0 && ['true', 'false'].includes(value);
|
|
15
|
+
},
|
|
16
|
+
defaultMessage(validationArguments) {
|
|
17
|
+
return `${validationArguments?.property} should be boolean`;
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
});
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
exports.IsNotEmptyBooleanString = IsNotEmptyBooleanString;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.IsNotEmptyBoolean = void 0;
|
|
4
|
+
const class_validator_1 = require("class-validator");
|
|
5
|
+
function IsNotEmptyBoolean(validationOptions) {
|
|
6
|
+
return function (object, propertyName) {
|
|
7
|
+
(0, class_validator_1.registerDecorator)({
|
|
8
|
+
name: 'IsNotEmptyBoolean',
|
|
9
|
+
target: object.constructor,
|
|
10
|
+
propertyName: propertyName,
|
|
11
|
+
options: validationOptions,
|
|
12
|
+
validator: {
|
|
13
|
+
validate(value) {
|
|
14
|
+
return typeof value === 'boolean';
|
|
15
|
+
},
|
|
16
|
+
defaultMessage(validationArguments) {
|
|
17
|
+
return `${validationArguments?.property} should be boolean`;
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
});
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
exports.IsNotEmptyBoolean = IsNotEmptyBoolean;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.IsNotEmptyNumberString = void 0;
|
|
27
|
+
const is_boolean_1 = require("../../util/is-boolean");
|
|
28
|
+
const is_boolean_2 = require("../../util/is-boolean");
|
|
29
|
+
const class_validator_1 = require("class-validator");
|
|
30
|
+
const FF = __importStar(require("fp-ts/function"));
|
|
31
|
+
const FO = __importStar(require("fp-ts/Option"));
|
|
32
|
+
function IsNotEmptyNumberString(validationOptions) {
|
|
33
|
+
return function (object, propertyName) {
|
|
34
|
+
(0, class_validator_1.registerDecorator)({
|
|
35
|
+
name: 'IsNotEmptyNumberString',
|
|
36
|
+
target: object.constructor,
|
|
37
|
+
propertyName: propertyName,
|
|
38
|
+
options: validationOptions,
|
|
39
|
+
validator: {
|
|
40
|
+
validate(value) {
|
|
41
|
+
const numberValue = Number(value);
|
|
42
|
+
const isNumber = typeof value === 'string' && value.length > 0 && (0, is_boolean_2.isFalse)(isNaN(numberValue));
|
|
43
|
+
return FF.pipe(validationOptions?.isFloat ?? false, FO.fromPredicate(predicate => (0, is_boolean_1.isTrue)(predicate)), FO.fold(() => (0, is_boolean_1.isTrue)(isNumber) && numberValue % 1 === 0, () => {
|
|
44
|
+
return (0, is_boolean_1.isTrue)(isNumber);
|
|
45
|
+
}));
|
|
46
|
+
},
|
|
47
|
+
defaultMessage(validationArguments) {
|
|
48
|
+
return `${validationArguments?.property} sould be number string`;
|
|
49
|
+
},
|
|
50
|
+
},
|
|
51
|
+
});
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
exports.IsNotEmptyNumberString = IsNotEmptyNumberString;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.IsNotEmptyNumber = void 0;
|
|
27
|
+
const is_boolean_1 = require("../../util/is-boolean");
|
|
28
|
+
const FF = __importStar(require("fp-ts/function"));
|
|
29
|
+
const FO = __importStar(require("fp-ts/Option"));
|
|
30
|
+
const class_validator_1 = require("class-validator");
|
|
31
|
+
const is_boolean_2 = require("../../util/is-boolean");
|
|
32
|
+
function IsNotEmptyNumber(validationOptions) {
|
|
33
|
+
return function (object, propertyName) {
|
|
34
|
+
(0, class_validator_1.registerDecorator)({
|
|
35
|
+
name: 'IsNotEmptyNumber',
|
|
36
|
+
target: object.constructor,
|
|
37
|
+
propertyName: propertyName,
|
|
38
|
+
options: validationOptions,
|
|
39
|
+
validator: {
|
|
40
|
+
validate(value) {
|
|
41
|
+
const isNumber = typeof value === 'number' && (0, is_boolean_2.isFalse)(isNaN(value));
|
|
42
|
+
return FF.pipe(validationOptions?.isFloat ?? false, FO.fromPredicate(predicate => (0, is_boolean_1.isTrue)(predicate)), FO.fold(() => (0, is_boolean_1.isTrue)(isNumber) && value % 1 === 0, () => (0, is_boolean_1.isTrue)(isNumber)));
|
|
43
|
+
},
|
|
44
|
+
defaultMessage(validationArguments) {
|
|
45
|
+
return `${validationArguments?.property} should be number`;
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
});
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
exports.IsNotEmptyNumber = IsNotEmptyNumber;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.IsNotEmptySqlDateString = void 0;
|
|
7
|
+
const dayjs_1 = __importDefault(require("dayjs"));
|
|
8
|
+
const customParseFormat_1 = __importDefault(require("dayjs/plugin/customParseFormat"));
|
|
9
|
+
const class_validator_1 = require("class-validator");
|
|
10
|
+
const is_empty_1 = require("../../util/is-empty");
|
|
11
|
+
dayjs_1.default.extend(customParseFormat_1.default);
|
|
12
|
+
function IsNotEmptySqlDateString(validationOptions) {
|
|
13
|
+
return function (object, propertyName) {
|
|
14
|
+
(0, class_validator_1.registerDecorator)({
|
|
15
|
+
name: 'IsNotEmptySqlDateString',
|
|
16
|
+
target: object.constructor,
|
|
17
|
+
propertyName: propertyName,
|
|
18
|
+
options: validationOptions,
|
|
19
|
+
validator: {
|
|
20
|
+
validate(value) {
|
|
21
|
+
return typeof value === 'string' && (0, is_empty_1.isNotEmpty)(value) && (0, dayjs_1.default)(value, 'YYYY-MM-DD', true).isValid();
|
|
22
|
+
},
|
|
23
|
+
defaultMessage(validationArguments) {
|
|
24
|
+
return `${validationArguments?.property} should be YYYY-MM-DD`;
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
});
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
exports.IsNotEmptySqlDateString = IsNotEmptySqlDateString;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.IsNotEmptySqlDateTimeString = void 0;
|
|
7
|
+
const dayjs_1 = __importDefault(require("dayjs"));
|
|
8
|
+
const customParseFormat_1 = __importDefault(require("dayjs/plugin/customParseFormat"));
|
|
9
|
+
const class_validator_1 = require("class-validator");
|
|
10
|
+
const is_empty_1 = require("../../util/is-empty");
|
|
11
|
+
dayjs_1.default.extend(customParseFormat_1.default);
|
|
12
|
+
function IsNotEmptySqlDateTimeString(validationOptions) {
|
|
13
|
+
return function (object, propertyName) {
|
|
14
|
+
(0, class_validator_1.registerDecorator)({
|
|
15
|
+
name: 'IsNotEmptySqlDateTimeString',
|
|
16
|
+
target: object.constructor,
|
|
17
|
+
propertyName: propertyName,
|
|
18
|
+
options: validationOptions,
|
|
19
|
+
validator: {
|
|
20
|
+
validate(value) {
|
|
21
|
+
return typeof value === 'string' && (0, is_empty_1.isNotEmpty)(value) && (0, dayjs_1.default)(value, 'YYYY-MM-DD HH:mm:ss', true).isValid();
|
|
22
|
+
},
|
|
23
|
+
defaultMessage(validationArguments) {
|
|
24
|
+
return `${validationArguments?.property} should be YYYY-MM-DD hh:mm:ss`;
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
});
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
exports.IsNotEmptySqlDateTimeString = IsNotEmptySqlDateTimeString;
|