querier-ts 2.1.0 → 2.1.1
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/README.md +17 -2
- package/lib/__tests__/query.spec.d.ts +1 -0
- package/lib/__tests__/query.spec.d.ts.map +1 -0
- package/lib/__tests__/query.spec.js +193 -87
- package/lib/__tests__/query.spec.js.map +1 -0
- package/lib/core/errors/__tests__/invalid-argument-error.spec.d.ts +1 -0
- package/lib/core/errors/__tests__/invalid-argument-error.spec.d.ts.map +1 -0
- package/lib/core/errors/__tests__/invalid-argument-error.spec.js +7 -45
- package/lib/core/errors/__tests__/invalid-argument-error.spec.js.map +1 -0
- package/lib/core/errors/invalid-argument-error.d.ts +1 -12
- package/lib/core/errors/invalid-argument-error.d.ts.map +1 -1
- package/lib/core/errors/invalid-argument-error.js +2 -8
- package/lib/core/errors/invalid-argument-error.js.map +1 -1
- package/lib/core/types/nullable-condition.d.ts +2 -0
- package/lib/core/types/nullable-condition.d.ts.map +1 -0
- package/lib/core/types/nullable-condition.js +2 -0
- package/lib/core/types/nullable-condition.js.map +1 -0
- package/lib/core/types/query-conditions-group-nullable.d.ts +2 -1
- package/lib/core/types/query-conditions-group-nullable.d.ts.map +1 -1
- package/lib/core/types/validation-options.d.ts +4 -0
- package/lib/core/types/validation-options.d.ts.map +1 -0
- package/lib/core/types/validation-options.js +2 -0
- package/lib/core/types/validation-options.js.map +1 -0
- package/lib/core/validation/__tests__/query-row-validator.spec.d.ts +1 -0
- package/lib/core/validation/__tests__/query-row-validator.spec.d.ts.map +1 -0
- package/lib/core/validation/__tests__/query-row-validator.spec.js +48 -87
- package/lib/core/validation/__tests__/query-row-validator.spec.js.map +1 -0
- package/lib/core/validation/decorators/__tests__/number-validation.spec.d.ts +2 -1
- package/lib/core/validation/decorators/__tests__/number-validation.spec.d.ts.map +1 -0
- package/lib/core/validation/decorators/__tests__/number-validation.spec.js +40 -24
- package/lib/core/validation/decorators/__tests__/number-validation.spec.js.map +1 -0
- package/lib/core/validation/decorators/number-validaton.d.ts.map +1 -1
- package/lib/core/validation/decorators/number-validaton.js +6 -18
- package/lib/core/validation/decorators/number-validaton.js.map +1 -1
- package/lib/core/validation/query-row-validator.d.ts +6 -40
- package/lib/core/validation/query-row-validator.d.ts.map +1 -1
- package/lib/core/validation/query-row-validator.js +22 -44
- package/lib/core/validation/query-row-validator.js.map +1 -1
- package/lib/query.d.ts +18 -17
- package/lib/query.d.ts.map +1 -1
- package/lib/query.js +57 -59
- package/lib/query.js.map +1 -1
- package/lib/utils/functions/generic/__tests__/compare-arrays.spec.d.ts +1 -0
- package/lib/utils/functions/generic/__tests__/compare-arrays.spec.d.ts.map +1 -0
- package/lib/utils/functions/generic/__tests__/compare-arrays.spec.js +6 -7
- package/lib/utils/functions/generic/__tests__/compare-arrays.spec.js.map +1 -0
- package/lib/utils/functions/generic/__tests__/deep-equal.spec.d.ts +1 -0
- package/lib/utils/functions/generic/__tests__/deep-equal.spec.d.ts.map +1 -0
- package/lib/utils/functions/generic/__tests__/deep-equal.spec.js +25 -26
- package/lib/utils/functions/generic/__tests__/deep-equal.spec.js.map +1 -0
- package/lib/utils/functions/generic/__tests__/get-entries.spec.d.ts +1 -0
- package/lib/utils/functions/generic/__tests__/get-entries.spec.d.ts.map +1 -0
- package/lib/utils/functions/generic/__tests__/get-entries.spec.js +7 -8
- package/lib/utils/functions/generic/__tests__/get-entries.spec.js.map +1 -0
- package/lib/utils/functions/generic/__tests__/get-object-property-names.spec.d.ts +2 -0
- package/lib/utils/functions/generic/__tests__/get-object-property-names.spec.d.ts.map +1 -0
- package/lib/utils/functions/generic/__tests__/get-object-property-names.spec.js +82 -0
- package/lib/utils/functions/generic/__tests__/get-object-property-names.spec.js.map +1 -0
- package/lib/utils/functions/sort/__tests__/sort-by-properties.spec.d.ts +1 -0
- package/lib/utils/functions/sort/__tests__/sort-by-properties.spec.d.ts.map +1 -0
- package/lib/utils/functions/sort/__tests__/sort-by-properties.spec.js +10 -11
- package/lib/utils/functions/sort/__tests__/sort-by-properties.spec.js.map +1 -0
- package/lib/utils/functions/sort/__tests__/sort-by-property.spec.d.ts +1 -0
- package/lib/utils/functions/sort/__tests__/sort-by-property.spec.d.ts.map +1 -0
- package/lib/utils/functions/sort/__tests__/sort-by-property.spec.js +24 -12
- package/lib/utils/functions/sort/__tests__/sort-by-property.spec.js.map +1 -0
- package/lib/utils/functions/type-guards/__tests__/is-function.spec.d.ts +1 -0
- package/lib/utils/functions/type-guards/__tests__/is-function.spec.d.ts.map +1 -0
- package/lib/utils/functions/type-guards/__tests__/is-function.spec.js +14 -15
- package/lib/utils/functions/type-guards/__tests__/is-function.spec.js.map +1 -0
- package/lib/utils/functions/type-guards/__tests__/is-number.spec.d.ts +1 -0
- package/lib/utils/functions/type-guards/__tests__/is-number.spec.d.ts.map +1 -0
- package/lib/utils/functions/type-guards/__tests__/is-number.spec.js +19 -20
- package/lib/utils/functions/type-guards/__tests__/is-number.spec.js.map +1 -0
- package/lib/utils/functions/type-guards/__tests__/is-object.spec.d.ts +1 -0
- package/lib/utils/functions/type-guards/__tests__/is-object.spec.d.ts.map +1 -0
- package/lib/utils/functions/type-guards/__tests__/is-object.spec.js +19 -20
- package/lib/utils/functions/type-guards/__tests__/is-object.spec.js.map +1 -0
- package/package.json +15 -13
|
@@ -1,26 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const query_row_validator_1 = require("../query-row-validator");
|
|
1
|
+
import { QueryRowValidator } from '../query-row-validator';
|
|
4
2
|
describe('QueryRowValidator', () => {
|
|
5
3
|
describe('primitive comparisons', () => {
|
|
6
4
|
it('should validate equality for primitive values', () => {
|
|
7
5
|
const row = { id: 1, name: 'Alice' };
|
|
8
|
-
const result =
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
name: 'Alice',
|
|
12
|
-
},
|
|
13
|
-
ignoreNullValues: false,
|
|
6
|
+
const result = QueryRowValidator.validate(row, {
|
|
7
|
+
id: 1,
|
|
8
|
+
name: 'Alice',
|
|
14
9
|
});
|
|
15
10
|
expect(result).toBe(true);
|
|
16
11
|
});
|
|
17
12
|
it('should return false when primitive values differ', () => {
|
|
18
13
|
const row = { id: 1 };
|
|
19
|
-
const result =
|
|
20
|
-
|
|
21
|
-
id: 2,
|
|
22
|
-
},
|
|
23
|
-
ignoreNullValues: false,
|
|
14
|
+
const result = QueryRowValidator.validate(row, {
|
|
15
|
+
id: 2,
|
|
24
16
|
});
|
|
25
17
|
expect(result).toBe(false);
|
|
26
18
|
});
|
|
@@ -28,21 +20,15 @@ describe('QueryRowValidator', () => {
|
|
|
28
20
|
describe('function conditions', () => {
|
|
29
21
|
it('should validate using a function condition', () => {
|
|
30
22
|
const row = { age: 30 };
|
|
31
|
-
const result =
|
|
32
|
-
|
|
33
|
-
age: (value) => value > 18,
|
|
34
|
-
},
|
|
35
|
-
ignoreNullValues: false,
|
|
23
|
+
const result = QueryRowValidator.validate(row, {
|
|
24
|
+
age: (value) => value > 18,
|
|
36
25
|
});
|
|
37
26
|
expect(result).toBe(true);
|
|
38
27
|
});
|
|
39
28
|
it('should return false when function condition fails', () => {
|
|
40
29
|
const row = { age: 15 };
|
|
41
|
-
const result =
|
|
42
|
-
|
|
43
|
-
age: (value) => value > 18,
|
|
44
|
-
},
|
|
45
|
-
ignoreNullValues: false,
|
|
30
|
+
const result = QueryRowValidator.validate(row, {
|
|
31
|
+
age: (value) => value > 18,
|
|
46
32
|
});
|
|
47
33
|
expect(result).toBe(false);
|
|
48
34
|
});
|
|
@@ -50,31 +36,22 @@ describe('QueryRowValidator', () => {
|
|
|
50
36
|
describe('array conditions', () => {
|
|
51
37
|
it('should validate arrays using strict comparison', () => {
|
|
52
38
|
const row = { tags: ['a', 'b'] };
|
|
53
|
-
const result =
|
|
54
|
-
|
|
55
|
-
tags: ['a', 'b'],
|
|
56
|
-
},
|
|
57
|
-
ignoreNullValues: false,
|
|
39
|
+
const result = QueryRowValidator.validate(row, {
|
|
40
|
+
tags: ['a', 'b'],
|
|
58
41
|
});
|
|
59
42
|
expect(result).toBe(true);
|
|
60
43
|
});
|
|
61
44
|
it('should return false for arrays with different values', () => {
|
|
62
45
|
const row = { tags: ['a', 'b'] };
|
|
63
|
-
const result =
|
|
64
|
-
|
|
65
|
-
tags: ['a', 'c'],
|
|
66
|
-
},
|
|
67
|
-
ignoreNullValues: false,
|
|
46
|
+
const result = QueryRowValidator.validate(row, {
|
|
47
|
+
tags: ['a', 'c'],
|
|
68
48
|
});
|
|
69
49
|
expect(result).toBe(false);
|
|
70
50
|
});
|
|
71
51
|
it('should return false if condition is array but value is not', () => {
|
|
72
52
|
const row = { tags: 'a,b' };
|
|
73
|
-
const result =
|
|
74
|
-
|
|
75
|
-
tags: ['a', 'b'],
|
|
76
|
-
},
|
|
77
|
-
ignoreNullValues: false,
|
|
53
|
+
const result = QueryRowValidator.validate(row, {
|
|
54
|
+
tags: ['a', 'b'],
|
|
78
55
|
});
|
|
79
56
|
expect(result).toBe(false);
|
|
80
57
|
});
|
|
@@ -87,14 +64,11 @@ describe('QueryRowValidator', () => {
|
|
|
87
64
|
age: 25,
|
|
88
65
|
},
|
|
89
66
|
};
|
|
90
|
-
const result =
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
age: (value) => value >= 18,
|
|
95
|
-
},
|
|
67
|
+
const result = QueryRowValidator.validate(row, {
|
|
68
|
+
user: {
|
|
69
|
+
name: 'John',
|
|
70
|
+
age: (value) => value >= 18,
|
|
96
71
|
},
|
|
97
|
-
ignoreNullValues: false,
|
|
98
72
|
});
|
|
99
73
|
expect(result).toBe(true);
|
|
100
74
|
});
|
|
@@ -105,13 +79,10 @@ describe('QueryRowValidator', () => {
|
|
|
105
79
|
age: 15,
|
|
106
80
|
},
|
|
107
81
|
};
|
|
108
|
-
const result =
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
age: (value) => value >= 18,
|
|
112
|
-
},
|
|
82
|
+
const result = QueryRowValidator.validate(row, {
|
|
83
|
+
user: {
|
|
84
|
+
age: (value) => value >= 18,
|
|
113
85
|
},
|
|
114
|
-
ignoreNullValues: false,
|
|
115
86
|
});
|
|
116
87
|
expect(result).toBe(false);
|
|
117
88
|
});
|
|
@@ -119,11 +90,8 @@ describe('QueryRowValidator', () => {
|
|
|
119
90
|
const row = {
|
|
120
91
|
user: 'John',
|
|
121
92
|
};
|
|
122
|
-
const result =
|
|
123
|
-
|
|
124
|
-
user: { name: 'John' },
|
|
125
|
-
},
|
|
126
|
-
ignoreNullValues: false,
|
|
93
|
+
const result = QueryRowValidator.validate(row, {
|
|
94
|
+
user: { name: 'John' },
|
|
127
95
|
});
|
|
128
96
|
expect(result).toBe(false);
|
|
129
97
|
});
|
|
@@ -131,31 +99,29 @@ describe('QueryRowValidator', () => {
|
|
|
131
99
|
describe('ignoreNullValues behavior', () => {
|
|
132
100
|
it('should ignore null conditions when ignoreNullValues is true', () => {
|
|
133
101
|
const row = { name: 'Alice' };
|
|
134
|
-
const result =
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
},
|
|
138
|
-
ignoreNullValues: true,
|
|
139
|
-
});
|
|
102
|
+
const result = QueryRowValidator.validate(row, {
|
|
103
|
+
name: null,
|
|
104
|
+
}, { ignoreNullValues: true });
|
|
140
105
|
expect(result).toBe(true);
|
|
141
106
|
});
|
|
142
107
|
it('should ignore undefined conditions when ignoreNullValues is true', () => {
|
|
143
108
|
const row = { name: 'Alice' };
|
|
144
|
-
const result =
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
},
|
|
148
|
-
ignoreNullValues: true,
|
|
149
|
-
});
|
|
109
|
+
const result = QueryRowValidator.validate(row, {
|
|
110
|
+
name: undefined,
|
|
111
|
+
}, { ignoreNullValues: true });
|
|
150
112
|
expect(result).toBe(true);
|
|
151
113
|
});
|
|
152
114
|
it('should NOT ignore null when ignoreNullValues is false', () => {
|
|
153
115
|
const row = { name: 'Alice' };
|
|
154
|
-
const result =
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
116
|
+
const result = QueryRowValidator.validate(row, {
|
|
117
|
+
name: null,
|
|
118
|
+
}, { ignoreNullValues: false });
|
|
119
|
+
expect(result).toBe(false);
|
|
120
|
+
});
|
|
121
|
+
it('should use default options (ignoreNullValues = false)', () => {
|
|
122
|
+
const row = { name: 'Alice' };
|
|
123
|
+
const result = QueryRowValidator.validate(row, {
|
|
124
|
+
name: null,
|
|
159
125
|
});
|
|
160
126
|
expect(result).toBe(false);
|
|
161
127
|
});
|
|
@@ -167,13 +133,10 @@ describe('QueryRowValidator', () => {
|
|
|
167
133
|
active: true,
|
|
168
134
|
roles: ['admin'],
|
|
169
135
|
};
|
|
170
|
-
const result =
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
roles: ['admin'],
|
|
175
|
-
},
|
|
176
|
-
ignoreNullValues: false,
|
|
136
|
+
const result = QueryRowValidator.validate(row, {
|
|
137
|
+
id: 1,
|
|
138
|
+
active: true,
|
|
139
|
+
roles: ['admin'],
|
|
177
140
|
});
|
|
178
141
|
expect(result).toBe(true);
|
|
179
142
|
});
|
|
@@ -182,14 +145,12 @@ describe('QueryRowValidator', () => {
|
|
|
182
145
|
id: 1,
|
|
183
146
|
active: false,
|
|
184
147
|
};
|
|
185
|
-
const result =
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
active: true,
|
|
189
|
-
},
|
|
190
|
-
ignoreNullValues: false,
|
|
148
|
+
const result = QueryRowValidator.validate(row, {
|
|
149
|
+
id: 1,
|
|
150
|
+
active: true,
|
|
191
151
|
});
|
|
192
152
|
expect(result).toBe(false);
|
|
193
153
|
});
|
|
194
154
|
});
|
|
195
155
|
});
|
|
156
|
+
//# sourceMappingURL=query-row-validator.spec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"query-row-validator.spec.js","sourceRoot":"","sources":["../../../../src/core/validation/__tests__/query-row-validator.spec.ts"],"names":[],"m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;QAC7B,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
export {};
|
|
2
|
+
//# sourceMappingURL=number-validation.spec.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"number-validation.spec.d.ts","sourceRoot":"","sources":["../../../../../src/core/validation/decorators/__tests__/number-validation.spec.ts"],"names":[],"mappings":""}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
2
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
3
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -8,10 +7,8 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
8
7
|
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
9
8
|
return function (target, key) { decorator(target, key, paramIndex); }
|
|
10
9
|
};
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
const errors_1 = require("../../../errors");
|
|
14
|
-
const number_validaton_1 = require("../number-validaton");
|
|
10
|
+
import { InvalidArgumentError } from '../../../errors';
|
|
11
|
+
import { integer, max, min, validateNumbers } from '../number-validaton';
|
|
15
12
|
class TestService {
|
|
16
13
|
sum(a, b, c) {
|
|
17
14
|
return a + b + c;
|
|
@@ -24,19 +21,19 @@ class TestService {
|
|
|
24
21
|
}
|
|
25
22
|
}
|
|
26
23
|
__decorate([
|
|
27
|
-
|
|
28
|
-
__param(0,
|
|
29
|
-
__param(1,
|
|
30
|
-
__param(2,
|
|
24
|
+
validateNumbers,
|
|
25
|
+
__param(0, min(0)),
|
|
26
|
+
__param(1, max(10)),
|
|
27
|
+
__param(2, integer)
|
|
31
28
|
], TestService.prototype, "sum", null);
|
|
32
29
|
__decorate([
|
|
33
|
-
|
|
34
|
-
__param(0,
|
|
30
|
+
validateNumbers,
|
|
31
|
+
__param(0, integer)
|
|
35
32
|
], TestService.prototype, "onlyInteger", null);
|
|
36
33
|
__decorate([
|
|
37
|
-
|
|
38
|
-
__param(0,
|
|
39
|
-
__param(0,
|
|
34
|
+
validateNumbers,
|
|
35
|
+
__param(0, min(5)),
|
|
36
|
+
__param(0, max(10))
|
|
40
37
|
], TestService.prototype, "ranged", null);
|
|
41
38
|
describe('number decorators', () => {
|
|
42
39
|
let service;
|
|
@@ -57,47 +54,65 @@ describe('number decorators', () => {
|
|
|
57
54
|
});
|
|
58
55
|
describe('min decorator', () => {
|
|
59
56
|
it('should throw if value is less than min', () => {
|
|
60
|
-
expect(() => service.sum(-1, 5, 3)).toThrow(
|
|
57
|
+
expect(() => service.sum(-1, 5, 3)).toThrow(InvalidArgumentError);
|
|
61
58
|
});
|
|
62
59
|
it('should throw with correct error message', () => {
|
|
63
60
|
try {
|
|
64
61
|
service.sum(-1, 5, 3);
|
|
65
62
|
}
|
|
66
63
|
catch (e) {
|
|
67
|
-
expect(e).toBeInstanceOf(
|
|
64
|
+
expect(e).toBeInstanceOf(InvalidArgumentError);
|
|
68
65
|
expect(e.message).toContain('equal or greater than 0');
|
|
69
66
|
}
|
|
70
67
|
});
|
|
71
68
|
});
|
|
72
69
|
describe('max decorator', () => {
|
|
73
70
|
it('should throw if value is greater than max', () => {
|
|
74
|
-
expect(() => service.sum(1, 20, 3)).toThrow(
|
|
71
|
+
expect(() => service.sum(1, 20, 3)).toThrow(InvalidArgumentError);
|
|
75
72
|
});
|
|
76
73
|
it('should throw with correct error message', () => {
|
|
77
74
|
try {
|
|
78
75
|
service.sum(1, 20, 3);
|
|
79
76
|
}
|
|
80
77
|
catch (e) {
|
|
81
|
-
expect(e).toBeInstanceOf(
|
|
78
|
+
expect(e).toBeInstanceOf(InvalidArgumentError);
|
|
82
79
|
expect(e.message).toContain('equal or less than 10');
|
|
83
80
|
}
|
|
84
81
|
});
|
|
82
|
+
describe('decorator override behavior', () => {
|
|
83
|
+
class OverrideService {
|
|
84
|
+
test(value) {
|
|
85
|
+
return value;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
__decorate([
|
|
89
|
+
validateNumbers,
|
|
90
|
+
__param(0, max(10)),
|
|
91
|
+
__param(0, max(5))
|
|
92
|
+
], OverrideService.prototype, "test", null);
|
|
93
|
+
const service = new OverrideService();
|
|
94
|
+
it('should override max value when decorator is applied multiple times', () => {
|
|
95
|
+
// valor final é 10 (último decorator executado)
|
|
96
|
+
expect(service.test(10)).toBe(10);
|
|
97
|
+
expect(() => service.test(11)).toThrow(InvalidArgumentError);
|
|
98
|
+
});
|
|
99
|
+
});
|
|
85
100
|
});
|
|
86
101
|
describe('integer decorator', () => {
|
|
87
102
|
it('should throw if value is not an integer', () => {
|
|
88
|
-
expect(() => service.onlyInteger(1.5)).toThrow(
|
|
103
|
+
expect(() => service.onlyInteger(1.5)).toThrow(InvalidArgumentError);
|
|
89
104
|
});
|
|
90
105
|
it('should accept safe integers', () => {
|
|
91
106
|
expect(service.onlyInteger(Number.MAX_SAFE_INTEGER)).toBe(Number.MAX_SAFE_INTEGER);
|
|
92
107
|
});
|
|
93
108
|
it('should throw if value is NaN', () => {
|
|
94
|
-
expect(() => service.onlyInteger(NaN)).toThrow(
|
|
109
|
+
expect(() => service.onlyInteger(NaN)).toThrow(InvalidArgumentError);
|
|
95
110
|
});
|
|
96
111
|
});
|
|
97
112
|
describe('combined decorators', () => {
|
|
98
113
|
it('should validate min and max together', () => {
|
|
99
|
-
expect(() => service.ranged(4)).toThrow(
|
|
100
|
-
expect(() => service.ranged(11)).toThrow(
|
|
114
|
+
expect(() => service.ranged(4)).toThrow(InvalidArgumentError);
|
|
115
|
+
expect(() => service.ranged(11)).toThrow(InvalidArgumentError);
|
|
101
116
|
});
|
|
102
117
|
it('should pass when all constraints are satisfied', () => {
|
|
103
118
|
expect(service.ranged(7)).toBe(7);
|
|
@@ -105,10 +120,11 @@ describe('number decorators', () => {
|
|
|
105
120
|
});
|
|
106
121
|
describe('type validation', () => {
|
|
107
122
|
it('should throw if value is not a number for min', () => {
|
|
108
|
-
expect(() => service.sum('1', 5, 3)).toThrow(
|
|
123
|
+
expect(() => service.sum('1', 5, 3)).toThrow(InvalidArgumentError);
|
|
109
124
|
});
|
|
110
125
|
it('should throw if value is not a number for max', () => {
|
|
111
|
-
expect(() => service.sum(1, '5', 3)).toThrow(
|
|
126
|
+
expect(() => service.sum(1, '5', 3)).toThrow(InvalidArgumentError);
|
|
112
127
|
});
|
|
113
128
|
});
|
|
114
129
|
});
|
|
130
|
+
//# sourceMappingURL=number-validation.spec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"number-validation.spec.js","sourceRoot":"","sources":["../../../../../src/core/validation/decorators/__tests__/number-validation.spec.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AACvD,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,GAAG,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAEzE,MAAM,WAAW;IAEf,GAAG,CAAS,CAAS,EAAW,CAAS,EAAW,CAAS;QAC3D,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IACnB,CAAC;IAGD,WAAW,CAAU,KAAa;QAChC,OAAO,KAAK,CAAC;IACf,CAAC;IAGD,MAAM,CAAkB,KAAa;QACnC,OAAO,KAAK,CAAC;IACf,CAAC;CACF;AAbC;IADC,eAAe;IACX,WAAA,GAAG,CAAC,CAAC,CAAC,CAAA;IAAa,WAAA,GAAG,CAAC,EAAE,CAAC,CAAA;IAAa,WAAA,OAAO,CAAA;sCAElD;AAGD;IADC,eAAe;IACH,WAAA,OAAO,CAAA;8CAEnB;AAGD;IADC,eAAe;IACR,WAAA,GAAG,CAAC,CAAC,CAAC,CAAA;IAAE,WAAA,GAA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,MAAM,GAAG,MAAM,EAC5B,KAAK,EAAE,MAAM,GACZ,IAAI,CAUN;AAED,wBAAgB,eAAe,CAC7B,MAAM,EAAE,MAAM,EACd,WAAW,EAAE,MAAM,EAEnB,UAAU,EAAE,uBAAuB,CAAC,GAAG,CAAC,GACvC,IAAI,
|
|
1
|
+
{"version":3,"file":"number-validaton.d.ts","sourceRoot":"","sources":["../../../../src/core/validation/decorators/number-validaton.ts"],"names":[],"mappings":"AAiCA,wBAAgB,GAAG,CAAC,KAAK,EAAE,MAAM,IAE7B,QAAQ,MAAM,EACd,aAAa,MAAM,GAAG,MAAM,EAC5B,OAAO,MAAM,KACZ,IAAI,CAWR;AAED,wBAAgB,GAAG,CAAC,KAAK,EAAE,MAAM,IAE7B,QAAQ,MAAM,EACd,aAAa,MAAM,GAAG,MAAM,EAC5B,OAAO,MAAM,KACZ,IAAI,CAWR;AAED,wBAAgB,OAAO,CACrB,MAAM,EAAE,MAAM,EACd,WAAW,EAAE,MAAM,GAAG,MAAM,EAC5B,KAAK,EAAE,MAAM,GACZ,IAAI,CAUN;AAED,wBAAgB,eAAe,CAC7B,MAAM,EAAE,MAAM,EACd,WAAW,EAAE,MAAM,EAEnB,UAAU,EAAE,uBAAuB,CAAC,GAAG,CAAC,GACvC,IAAI,CA0CN"}
|
|
@@ -59,34 +59,22 @@ descriptor) {
|
|
|
59
59
|
// MIN
|
|
60
60
|
if (rule.min !== undefined) {
|
|
61
61
|
if (!isNumber(value) || value < rule.min) {
|
|
62
|
-
throw new InvalidArgumentError({
|
|
63
|
-
|
|
64
|
-
param: rule.index,
|
|
65
|
-
argument: value,
|
|
66
|
-
expected: `equal or greater than ${rule.min}`,
|
|
67
|
-
});
|
|
62
|
+
throw new InvalidArgumentError(`${String(value)} is not a valid argument to param ${rule.index} on ${propertyKey}(). ` +
|
|
63
|
+
`Expected value to be equal or greater than ${rule.min}.`);
|
|
68
64
|
}
|
|
69
65
|
}
|
|
70
66
|
// MAX
|
|
71
67
|
if (rule.max !== undefined) {
|
|
72
68
|
if (!isNumber(value) || value > rule.max) {
|
|
73
|
-
throw new InvalidArgumentError({
|
|
74
|
-
|
|
75
|
-
param: rule.index,
|
|
76
|
-
argument: value,
|
|
77
|
-
expected: `equal or less than ${rule.max}`,
|
|
78
|
-
});
|
|
69
|
+
throw new InvalidArgumentError(`${String(value)} is not a valid argument to param ${rule.index} on ${propertyKey}(). ` +
|
|
70
|
+
`Expected value to be equal or less than ${rule.max}.`);
|
|
79
71
|
}
|
|
80
72
|
}
|
|
81
73
|
// INTEGER
|
|
82
74
|
if (rule.integer) {
|
|
83
75
|
if (!Number.isSafeInteger(value)) {
|
|
84
|
-
throw new InvalidArgumentError({
|
|
85
|
-
|
|
86
|
-
param: rule.index,
|
|
87
|
-
argument: value,
|
|
88
|
-
expected: 'an integer',
|
|
89
|
-
});
|
|
76
|
+
throw new InvalidArgumentError(`${String(value)} is not a valid argument to param ${rule.index} on ${propertyKey}(). ` +
|
|
77
|
+
`Expected value to be an integer.`);
|
|
90
78
|
}
|
|
91
79
|
}
|
|
92
80
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"number-validaton.js","sourceRoot":"","sources":["../../../../src/core/validation/decorators/number-validaton.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,sCAAsC,CAAC;AAChE,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AASpD,MAAM,QAAQ,GAAG,IAAI,OAAO,EAAmD,CAAC;AAEhF,SAAS,SAAS,CAChB,MAAc,EACd,WAA4B;IAE5B,IAAI,OAAO,GAAG,QAAQ,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;IAEnC,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,OAAO,GAAG,IAAI,GAAG,EAAE,CAAC;QACpB,QAAQ,CAAC,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAChC,CAAC;IAED,IAAI,MAAM,GAAG,OAAO,CAAC,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,QAAQ,CAAC,KAAK,CAAC,IAAI,KAAK,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;oBACzC,MAAM,IAAI,oBAAoB,CAC5B,GAAG,MAAM,CAAC,KAAK,CAAC,qCAAqC,IAAI,CAAC,KAAK,OAAO,WAAW,MAAM;wBACrF,8CAA8C,IAAI,CAAC,GAAG,GAAG,CAC5D,CAAC;gBACJ,CAAC;YACH,CAAC;YAED,MAAM;YACN,IAAI,IAAI,CAAC,GAAG,KAAK,SAAS,EAAE,CAAC;gBAC3B,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,KAAK,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;oBACzC,MAAM,IAAI,oBAAoB,CAC5B,GAAG,MAAM,CAAC,KAAK,CAAC,qCAAqC,IAAI,CAAC,KAAK,OAAO,WAAW,MAAM;wBACrF,2CAA2C,IAAI,CAAC,GAAG,GAAG,CACzD,CAAC;gBACJ,CAAC;YACH,CAAC;YAED,UAAU;YACV,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;gBACjB,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,KAAK,CAAC,EAAE,CAAC;oBACjC,MAAM,IAAI,oBAAoB,CAC5B,GAAG,MAAM,CAAC,KAAK,CAAC,qCAAqC,IAAI,CAAC,KAAK,OAAO,WAAW,MAAM;wBACrF,kCAAkC,CACrC,CAAC;gBACJ,CAAC;YACH,CAAC;QACH,CAAC;QAED,OAAO,QAAQ,CAAC,KAAK,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IACpC,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -1,41 +1,16 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { QueryConditionsGroupNullable } from '../types';
|
|
2
|
+
import type { ValidationOptions } from '../types/validation-options';
|
|
2
3
|
/**
|
|
3
4
|
* Validates a row in the query.
|
|
4
5
|
*/
|
|
5
|
-
export declare class QueryRowValidator
|
|
6
|
-
|
|
7
|
-
* Row to be validated.
|
|
8
|
-
*/
|
|
9
|
-
private row;
|
|
10
|
-
/**
|
|
11
|
-
* Conditions to be applied to the row.
|
|
12
|
-
*/
|
|
13
|
-
private conditionsObject;
|
|
14
|
-
/**
|
|
15
|
-
* Indicates whether conditions with `null` and `undefined` values should be
|
|
16
|
-
* skipped.
|
|
17
|
-
*/
|
|
18
|
-
private ignoreNullValues;
|
|
19
|
-
/**
|
|
20
|
-
* Initializes the validator.
|
|
21
|
-
*
|
|
22
|
-
* @param row Row to validated.
|
|
23
|
-
* @param config Validator configuration.
|
|
24
|
-
*/
|
|
25
|
-
private constructor();
|
|
26
|
-
/**
|
|
27
|
-
* Validates a row.
|
|
28
|
-
*
|
|
29
|
-
* @param row Row to validated.
|
|
30
|
-
* @param config Validator configuration.
|
|
31
|
-
*/
|
|
32
|
-
static validate<T extends object>(row: T, config: QueryRowValidatorInitializer<T>): boolean;
|
|
6
|
+
export declare class QueryRowValidator {
|
|
7
|
+
#private;
|
|
33
8
|
/**
|
|
34
9
|
* Validates all conditions of the row.
|
|
35
10
|
*
|
|
36
11
|
* @returns Validation result.
|
|
37
12
|
*/
|
|
38
|
-
|
|
13
|
+
static validate<T extends object>(row: T, condition: QueryConditionsGroupNullable<T>, options?: ValidationOptions): boolean;
|
|
39
14
|
/**
|
|
40
15
|
* Validate a condition to a specific column.
|
|
41
16
|
*
|
|
@@ -44,15 +19,6 @@ export declare class QueryRowValidator<T extends object> {
|
|
|
44
19
|
*
|
|
45
20
|
* @returns Validation result.
|
|
46
21
|
*/
|
|
47
|
-
private validateColumnCondition;
|
|
48
|
-
/**
|
|
49
|
-
* Validates an object inside the row.
|
|
50
|
-
*
|
|
51
|
-
* @param obj Object to validated.
|
|
52
|
-
* @param conditionsObject Conditions to be applied to the object.
|
|
53
|
-
*
|
|
54
|
-
* @returns Validation result.
|
|
55
|
-
*/
|
|
56
|
-
private validateInnerObject;
|
|
22
|
+
private static validateColumnCondition;
|
|
57
23
|
}
|
|
58
24
|
//# sourceMappingURL=query-row-validator.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"query-row-validator.d.ts","sourceRoot":"","sources":["../../../src/core/validation/query-row-validator.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"query-row-validator.d.ts","sourceRoot":"","sources":["../../../src/core/validation/query-row-validator.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAEV,4BAA4B,EAC7B,MAAM,UAAU,CAAC;AAElB,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAErE;;GAEG;AACH,qBAAa,iBAAiB;;IAK5B;;;;OAIG;IACH,MAAM,CAAC,QAAQ,CAAC,CAAC,SAAS,MAAM,EAC9B,GAAG,EAAE,CAAC,EACN,SAAS,EAAE,4BAA4B,CAAC,CAAC,CAAC,EAC1C,OAAO,CAAC,EAAE,iBAAiB,GAC1B,OAAO;IAiBV;;;;;;;OAOG;IACH,OAAO,CAAC,MAAM,CAAC,uBAAuB;CAkCvC"}
|
|
@@ -1,38 +1,28 @@
|
|
|
1
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
2
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
3
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
4
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
5
|
+
};
|
|
6
|
+
var _a, _QueryRowValidator_defaultOptions;
|
|
1
7
|
import { compareArrays, getEntries } from '../../utils/functions/generic';
|
|
2
8
|
import { isFunction, isObject } from '../../utils/functions/type-guards';
|
|
3
9
|
/**
|
|
4
10
|
* Validates a row in the query.
|
|
5
11
|
*/
|
|
6
12
|
export class QueryRowValidator {
|
|
7
|
-
/**
|
|
8
|
-
* Initializes the validator.
|
|
9
|
-
*
|
|
10
|
-
* @param row Row to validated.
|
|
11
|
-
* @param config Validator configuration.
|
|
12
|
-
*/
|
|
13
|
-
constructor(row, config) {
|
|
14
|
-
this.row = row;
|
|
15
|
-
this.conditionsObject = config.conditionsObject;
|
|
16
|
-
this.ignoreNullValues = config.ignoreNullValues;
|
|
17
|
-
}
|
|
18
|
-
/**
|
|
19
|
-
* Validates a row.
|
|
20
|
-
*
|
|
21
|
-
* @param row Row to validated.
|
|
22
|
-
* @param config Validator configuration.
|
|
23
|
-
*/
|
|
24
|
-
static validate(row, config) {
|
|
25
|
-
const validator = new QueryRowValidator(row, config);
|
|
26
|
-
return validator.validate();
|
|
27
|
-
}
|
|
28
13
|
/**
|
|
29
14
|
* Validates all conditions of the row.
|
|
30
15
|
*
|
|
31
16
|
* @returns Validation result.
|
|
32
17
|
*/
|
|
33
|
-
validate() {
|
|
34
|
-
const
|
|
35
|
-
|
|
18
|
+
static validate(row, condition, options) {
|
|
19
|
+
for (const [column, columnCondition] of getEntries(condition)) {
|
|
20
|
+
const validated = this.validateColumnCondition(row, column, columnCondition, options ?? __classPrivateFieldGet(this, _a, "f", _QueryRowValidator_defaultOptions));
|
|
21
|
+
if (!validated) {
|
|
22
|
+
return false;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
return true;
|
|
36
26
|
}
|
|
37
27
|
/**
|
|
38
28
|
* Validate a condition to a specific column.
|
|
@@ -42,12 +32,12 @@ export class QueryRowValidator {
|
|
|
42
32
|
*
|
|
43
33
|
* @returns Validation result.
|
|
44
34
|
*/
|
|
45
|
-
validateColumnCondition(
|
|
46
|
-
if (
|
|
35
|
+
static validateColumnCondition(row, column, condition, options) {
|
|
36
|
+
if (options.ignoreNullValues &&
|
|
47
37
|
(condition === null || condition === undefined)) {
|
|
48
38
|
return true;
|
|
49
39
|
}
|
|
50
|
-
const cellValue =
|
|
40
|
+
const cellValue = row[column];
|
|
51
41
|
if (isFunction(condition)) {
|
|
52
42
|
return condition(cellValue);
|
|
53
43
|
}
|
|
@@ -57,25 +47,13 @@ export class QueryRowValidator {
|
|
|
57
47
|
: false;
|
|
58
48
|
}
|
|
59
49
|
if (isObject(condition)) {
|
|
60
|
-
return isObject(cellValue)
|
|
61
|
-
? this.validateInnerObject(cellValue, condition)
|
|
62
|
-
: false;
|
|
50
|
+
return isObject(cellValue) ? this.validate(cellValue, condition) : false;
|
|
63
51
|
}
|
|
64
52
|
return cellValue === condition;
|
|
65
53
|
}
|
|
66
|
-
/**
|
|
67
|
-
* Validates an object inside the row.
|
|
68
|
-
*
|
|
69
|
-
* @param obj Object to validated.
|
|
70
|
-
* @param conditionsObject Conditions to be applied to the object.
|
|
71
|
-
*
|
|
72
|
-
* @returns Validation result.
|
|
73
|
-
*/
|
|
74
|
-
validateInnerObject(obj, conditionsObject) {
|
|
75
|
-
return QueryRowValidator.validate(obj, {
|
|
76
|
-
conditionsObject,
|
|
77
|
-
ignoreNullValues: this.ignoreNullValues,
|
|
78
|
-
});
|
|
79
|
-
}
|
|
80
54
|
}
|
|
55
|
+
_a = QueryRowValidator;
|
|
56
|
+
_QueryRowValidator_defaultOptions = { value: {
|
|
57
|
+
ignoreNullValues: false,
|
|
58
|
+
} };
|
|
81
59
|
//# sourceMappingURL=query-row-validator.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"query-row-validator.js","sourceRoot":"","sources":["../../../src/core/validation/query-row-validator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAC1E,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,mCAAmC,CAAC;AAQzE;;GAEG;AACH,MAAM,OAAO,iBAAiB;
|
|
1
|
+
{"version":3,"file":"query-row-validator.js","sourceRoot":"","sources":["../../../src/core/validation/query-row-validator.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAC1E,OAAO,EAAE,UAAU,EAA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