@punks/backend-entity-manager 0.0.379 → 0.0.381

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/cjs/index.js CHANGED
@@ -201,8 +201,14 @@ class EntitySeeder {
201
201
  const normalizeSheetColumn = (column) => column.replace(/ /g, "").toLowerCase();
202
202
  const DEFAULT_DELIMITER = ";";
203
203
  const DEFAULT_ARRAY_SEPARATOR = "|";
204
- const splitArrayColumn = (value, separator) => value?.toString().split(separator ?? DEFAULT_ARRAY_SEPARATOR);
205
- const joinArrayColumn = (value, separator) => value?.map((x) => x.toString()).join(separator ?? DEFAULT_ARRAY_SEPARATOR);
204
+ const splitArrayColumn = (value, separator) => value
205
+ ?.toString()
206
+ .split(separator ?? DEFAULT_ARRAY_SEPARATOR)
207
+ .filter((x) => x.trim());
208
+ const joinArrayColumn = (value, separator) => value
209
+ ?.map((x) => x.toString().trim())
210
+ .filter((x) => x)
211
+ .join(separator ?? DEFAULT_ARRAY_SEPARATOR);
206
212
  class EntitySerializer {
207
213
  constructor(services, options) {
208
214
  this.services = services;
@@ -272,13 +278,16 @@ class EntitySerializer {
272
278
  for (const validator of column.validators ?? []) {
273
279
  const result = validator.fn(entity);
274
280
  if (!result.isValid) {
275
- validationErrors.push({
276
- errorCode: validator.key,
277
- column: {
278
- name: column.name,
279
- key: column.key,
280
- },
281
- });
281
+ for (const error of result.validationErrors) {
282
+ validationErrors.push({
283
+ errorCode: error.errorCode,
284
+ column: {
285
+ name: column.name,
286
+ key: column.key,
287
+ value: error.value,
288
+ },
289
+ });
290
+ }
282
291
  }
283
292
  }
284
293
  }
@@ -40743,7 +40752,7 @@ const fieldOptionValidator = (item, selector, { availableOptions, required, }) =
40743
40752
  };
40744
40753
  };
40745
40754
  const fieldOptionsValidator = (item, selector, { availableOptions, minSelected, maxSelected, }) => {
40746
- const values = selector(item);
40755
+ const values = selector(item).filter((x) => x) ?? [];
40747
40756
  const errors = [];
40748
40757
  const invalidOptions = values.filter((x) => !availableOptions.includes(x));
40749
40758
  invalidOptions.forEach((x) => errors.push({ errorCode: "invalidOption", value: x }));