@autofleet/sadot 0.13.5-beta-2 → 0.13.5-beta-4
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/hooks/hooks.js +6 -2
- package/package.json +1 -1
- package/src/hooks/hooks.ts +7 -3
package/dist/hooks/hooks.js
CHANGED
|
@@ -191,7 +191,9 @@ const validateModel = async (instance, options, scopeAttributes, modelOptions =
|
|
|
191
191
|
if (!isValid) {
|
|
192
192
|
const errorDetails = validateSchema.errors?.map((err) => `${err.instancePath || ''} ${err.message || 'Invalid value'}`).join(', ');
|
|
193
193
|
const formattedErrors = formatAjvErrors(validateSchema.errors);
|
|
194
|
-
throw new errors_1.BadRequest([new Error(`Validation failed for ${modelType}: ${errorDetails}`)], undefined,
|
|
194
|
+
throw new errors_1.BadRequest([new Error(`Validation failed for ${modelType}: ${errorDetails}`)], undefined, {
|
|
195
|
+
customError: formattedErrors,
|
|
196
|
+
});
|
|
195
197
|
}
|
|
196
198
|
}
|
|
197
199
|
}
|
|
@@ -221,7 +223,9 @@ const validateModel = async (instance, options, scopeAttributes, modelOptions =
|
|
|
221
223
|
.errors
|
|
222
224
|
?.map((err) => `${err.instancePath || ''} ${err.message || 'Invalid value'}`).join(', ');
|
|
223
225
|
const formattedErrors = formatAjvErrors(validateSchema.errors);
|
|
224
|
-
throw new errors_1.BadRequest([new Error(`Validation failed for ${modelType}: ${errorDetails}`)], undefined,
|
|
226
|
+
throw new errors_1.BadRequest([new Error(`Validation failed for ${modelType}: ${errorDetails}`)], undefined, {
|
|
227
|
+
customError: formattedErrors,
|
|
228
|
+
});
|
|
225
229
|
}
|
|
226
230
|
}
|
|
227
231
|
}
|
package/package.json
CHANGED
package/src/hooks/hooks.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { WhereOptions } from 'sequelize';
|
|
2
2
|
import Ajv from 'ajv';
|
|
3
|
-
import Joi from 'joi';
|
|
3
|
+
import Joi, { custom } from 'joi';
|
|
4
4
|
import addFormats from 'ajv-formats';
|
|
5
5
|
import { BadRequest } from '@autofleet/errors';
|
|
6
6
|
import ajvErrors from 'ajv-errors';
|
|
@@ -222,7 +222,9 @@ const validateModel = async (
|
|
|
222
222
|
throw new BadRequest(
|
|
223
223
|
[new Error(`Validation failed for ${modelType}: ${errorDetails}`)],
|
|
224
224
|
undefined,
|
|
225
|
-
|
|
225
|
+
{
|
|
226
|
+
customError: formattedErrors,
|
|
227
|
+
},
|
|
226
228
|
);
|
|
227
229
|
}
|
|
228
230
|
}
|
|
@@ -262,7 +264,9 @@ const validateModel = async (
|
|
|
262
264
|
throw new BadRequest(
|
|
263
265
|
[new Error(`Validation failed for ${modelType}: ${errorDetails}`)],
|
|
264
266
|
undefined,
|
|
265
|
-
|
|
267
|
+
{
|
|
268
|
+
customError: formattedErrors,
|
|
269
|
+
},
|
|
266
270
|
);
|
|
267
271
|
}
|
|
268
272
|
}
|