nox-validation 1.7.4 → 1.7.6

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.
Files changed (2) hide show
  1. package/lib/validate.js +11 -6
  2. package/package.json +1 -1
package/lib/validate.js CHANGED
@@ -496,7 +496,7 @@ const validateMetaRules = (
496
496
  label: node.display_label,
497
497
  }),
498
498
  actionFn: (node) => {
499
- const normalize = (path) => path.replace(/\[\d+\]/g, "[]");
499
+ const normalize = (path) => path.replace(/\[\d+\]/g, "");
500
500
 
501
501
  const getRoot = (path) => normalize(path).split(".")[0];
502
502
 
@@ -537,9 +537,14 @@ const validateMetaRules = (
537
537
  !normalize(fPath).startsWith(normalize(currentPath)) &&
538
538
  getRoot(fPath) !== getRoot(currentPath)
539
539
  ) {
540
- if (currentPath.includes(fPath)) {
541
- fPath = currentPath;
542
- } else fPath = `${currentPath}.${fPath}`;
540
+ if (!currentPath.includes(fPath)) {
541
+ fPath = `${currentPath}.${fPath}`;
542
+ }
543
+ } else if (
544
+ fPath !== currentPath &&
545
+ fPath?.length < currentPath?.length
546
+ ) {
547
+ fPath = currentPath;
543
548
  }
544
549
 
545
550
  // if (
@@ -570,7 +575,7 @@ const validateMetaRules = (
570
575
  language_codes.forEach((lang, index) => {
571
576
  let langPath, transformedPath;
572
577
  let isAdded = false;
573
- // // Check if current language entry exists in fieldValue.create
578
+ // Check if current language entry exists in fieldValue.create
574
579
  if (
575
580
  Array.isArray(fieldValue?.create) &&
576
581
  fieldValue?.create.some((item, idx) => {
@@ -1533,7 +1538,7 @@ const validate = (data) => {
1533
1538
  }
1534
1539
  }
1535
1540
 
1536
- result.errors[fieldPath] = obj;
1541
+ result.errors[fieldPath] = { ...obj, fieldId: field?.field_id };
1537
1542
  result.status = false;
1538
1543
  }
1539
1544
  if (abortEarly && !result.status) return result;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nox-validation",
3
- "version": "1.7.4",
3
+ "version": "1.7.6",
4
4
  "description": "validate dynamic schema",
5
5
  "main": "index.js",
6
6
  "scripts": {