@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.
@@ -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, formattedErrors);
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, formattedErrors);
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@autofleet/sadot",
3
- "version": "0.13.5-beta-2",
3
+ "version": "0.13.5-beta-4",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
@@ -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
- formattedErrors,
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
- formattedErrors,
267
+ {
268
+ customError: formattedErrors,
269
+ },
266
270
  );
267
271
  }
268
272
  }