@webitel/api-services 26.8.51 → 26.8.52
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/package.json
CHANGED
|
@@ -92,12 +92,13 @@ describe('queueSchema', () => {
|
|
|
92
92
|
it.each(allQueueTypes)('enforces every required field of type %i', (type) => {
|
|
93
93
|
for (const path of requiredPathsFor(type)) {
|
|
94
94
|
const queue = validQueueFor(type);
|
|
95
|
-
|
|
95
|
+
const isLookup = lookupPaths.has(path);
|
|
96
|
+
set(queue, path, isLookup ? {} : '');
|
|
96
97
|
|
|
97
98
|
expect(
|
|
98
99
|
issuePaths(queueSchema.safeParse(queue)),
|
|
99
100
|
`${path} should be required for type ${type}`,
|
|
100
|
-
).toContain(path);
|
|
101
|
+
).toContain(isLookup ? `${path}.id` : path);
|
|
101
102
|
}
|
|
102
103
|
});
|
|
103
104
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { get } from 'lodash-es';
|
|
1
|
+
import { get, isPlainObject } from 'lodash-es';
|
|
2
2
|
import { z } from 'zod';
|
|
3
3
|
|
|
4
4
|
import { clearableNumberSchema } from '../_shared/clearableNumber.validations';
|
|
@@ -74,10 +74,16 @@ export const queueSchema = queueSchemaBase.superRefine((queue, ctx) => {
|
|
|
74
74
|
|
|
75
75
|
for (const rule of rules) {
|
|
76
76
|
for (const path of rule.required ?? []) {
|
|
77
|
-
|
|
77
|
+
const value = get(queue, path);
|
|
78
|
+
if (!isFilled(value)) {
|
|
78
79
|
ctx.addIssue({
|
|
79
80
|
code: 'custom',
|
|
80
|
-
path:
|
|
81
|
+
path: isPlainObject(value)
|
|
82
|
+
? [
|
|
83
|
+
...path.split('.'),
|
|
84
|
+
'id',
|
|
85
|
+
]
|
|
86
|
+
: path.split('.'),
|
|
81
87
|
...i18nIssue('required'),
|
|
82
88
|
});
|
|
83
89
|
}
|