nox-validation 1.4.9 → 1.5.1

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/lib/helpers.js CHANGED
@@ -1376,7 +1376,9 @@ const getSelectedNodes = ({
1376
1376
  ...child,
1377
1377
  key:
1378
1378
  currentNode.type === constants.types.ARRAY
1379
- ? child.key.replace(currentNode.key, `${currentNode.key}[0]`)
1379
+ ? child.key.includes(`${currentNode.key}[`)
1380
+ ? child.key
1381
+ : child.key.replace(currentNode.key, `${currentNode.key}[0]`)
1380
1382
  : child.key,
1381
1383
  };
1382
1384
 
@@ -1393,13 +1395,6 @@ const getSelectedNodes = ({
1393
1395
  }
1394
1396
  return updatedNode;
1395
1397
  };
1396
- if (currentNode.type === constants.types.ARRAY) {
1397
- childNode = updateChildKeys(
1398
- child,
1399
- currentNode.key,
1400
- `${currentNode.key}[0]`
1401
- );
1402
- }
1403
1398
  }
1404
1399
 
1405
1400
  if (!skipFn(currentNode)) traverse(childNode);
package/lib/validate.js CHANGED
@@ -177,7 +177,7 @@ const isEmptyRelational = ({
177
177
  value,
178
178
  interface,
179
179
  onlyFormFields,
180
- existingValue,
180
+ existingValue = null,
181
181
  }) => {
182
182
  if (!onlyFormFields) {
183
183
  if (
@@ -219,12 +219,12 @@ const isEmptyRelational = ({
219
219
  case constants.interfaces.ONE_TO_MANY:
220
220
  case constants.interfaces.MANY_TO_ONE:
221
221
  return remainingItems({
222
- all: existingValue.map((item) => item._id),
222
+ all: existingValue?.map((item) => item._id),
223
223
  obj: value,
224
224
  });
225
225
  case constants.interfaces.MANY_TO_ANY:
226
226
  return remainingItems({
227
- all: existingValue.map((item) => item.item),
227
+ all: existingValue?.map((item) => item.item),
228
228
  obj: value,
229
229
  isM2A: true,
230
230
  });
@@ -256,7 +256,7 @@ const validateMetaRules = (
256
256
 
257
257
  let {
258
258
  required = false,
259
- nullable = false,
259
+ nullable = true,
260
260
  options,
261
261
  is_m2a_item,
262
262
  } = field?.meta ?? {};
@@ -406,10 +406,10 @@ const validateMetaRules = (
406
406
  }),
407
407
  actionFn: (node) => {
408
408
  let fPath = node.key;
409
- if (fPath.includes("update.")) return;
410
- if (fPath.includes("create.") && !isTranslationChild) return;
411
- if (fPath.includes("delete.") && !isTranslationChild) return;
412
- if (fPath.includes("existing.") && !isTranslationChild) return;
409
+ if (fPath.includes("update")) return;
410
+ if (fPath.includes("create") && !isTranslationChild) return;
411
+ if (fPath.includes("delete") && !isTranslationChild) return;
412
+ if (fPath.includes("existing") && !isTranslationChild) return;
413
413
 
414
414
  const label = formatLabel(node.display_label);
415
415
  const message = error_messages.REQUIRED.replace("{field}", label);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nox-validation",
3
- "version": "1.4.9",
3
+ "version": "1.5.1",
4
4
  "description": "validate dynamic schema",
5
5
  "main": "index.js",
6
6
  "scripts": {