@webitel/api-services 26.8.22 → 26.8.23
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
|
@@ -118,6 +118,21 @@ describe('queueSchema', () => {
|
|
|
118
118
|
}
|
|
119
119
|
});
|
|
120
120
|
|
|
121
|
+
/** A message here would reach the ui untranslated. WTEL-10294 */
|
|
122
|
+
it('reports a below-minimum number as too_small, without a message', () => {
|
|
123
|
+
const queue = validQueueFor(QueueType.INBOUND_QUEUE);
|
|
124
|
+
queue.priority = -1;
|
|
125
|
+
|
|
126
|
+
const issue = queueSchema
|
|
127
|
+
.safeParse(queue)
|
|
128
|
+
.error?.issues.find((i) => i.path.join('.') === 'priority');
|
|
129
|
+
|
|
130
|
+
expect(issue).toMatchObject({
|
|
131
|
+
code: 'too_small',
|
|
132
|
+
minimum: 0,
|
|
133
|
+
});
|
|
134
|
+
});
|
|
135
|
+
|
|
121
136
|
/** Vuelidate's `required` treats 0 and false as filled; ours must too. */
|
|
122
137
|
it('treats a zero priority as filled rather than missing', () => {
|
|
123
138
|
const queue = validQueueFor(QueueType.INBOUND_QUEUE);
|
|
@@ -88,10 +88,17 @@ export const queueSchema = queueSchemaBase.superRefine((queue, ctx) => {
|
|
|
88
88
|
// an absent optional field is the `required` rules' business, not this one
|
|
89
89
|
if (value === undefined || value === null || value === '') continue;
|
|
90
90
|
if (Number(value) < min) {
|
|
91
|
+
/**
|
|
92
|
+
* `too_small`, not a message: a message wins over the app's error
|
|
93
|
+
* map, the only thing that translates. WTEL-10294
|
|
94
|
+
*/
|
|
91
95
|
ctx.addIssue({
|
|
92
|
-
code: '
|
|
96
|
+
code: 'too_small',
|
|
97
|
+
origin: 'number',
|
|
98
|
+
minimum: min,
|
|
99
|
+
inclusive: true,
|
|
100
|
+
input: value,
|
|
93
101
|
path: path.split('.'),
|
|
94
|
-
message: `Value must be ${min} or greater`,
|
|
95
102
|
});
|
|
96
103
|
}
|
|
97
104
|
}
|