nox-validation 1.6.8 → 1.7.0

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/validate.js CHANGED
@@ -447,7 +447,9 @@ const validateMetaRules = (
447
447
  // Translations interface needs to be handled
448
448
  (field?.meta?.interface === constants.interfaces.TRANSLATIONS &&
449
449
  language_codes?.length &&
450
- !onlyFormFields) ||
450
+ (onlyFormFields
451
+ ? isEmpty(getValue(existingForm, currentPath))
452
+ : true)) ||
451
453
  // OBJECT or ITEMS interfaces
452
454
  ((field?.meta?.interface === constants.interfaces.OBJECT ||
453
455
  field?.meta?.interface === constants.interfaces.ITEMS) &&
@@ -486,7 +488,11 @@ const validateMetaRules = (
486
488
  ? extractFirstType(node.key)
487
489
  : null;
488
490
 
489
- if (!fPath.includes(currentPath)) {
491
+ if (
492
+ currentPath &&
493
+ currentPath?.trim() !== "" &&
494
+ !fPath.includes(currentPath)
495
+ ) {
490
496
  fPath = `${currentPath}.${fPath}`;
491
497
  }
492
498
 
@@ -542,7 +548,9 @@ const validateMetaRules = (
542
548
  node.value,
543
549
  node.key,
544
550
  (path) => {
545
- const newPath = path.replace(/\[0\]\./, `.${lang}.`);
551
+ const newPath = path
552
+ .replace(/\[0\]\./, `.${lang}.`)
553
+ ?.replace("create", "");
546
554
  return newPath;
547
555
  }
548
556
  );
@@ -552,7 +560,7 @@ const validateMetaRules = (
552
560
  });
553
561
 
554
562
  transformedPath = rebuildFullPath(node.value, node.key, (path) =>
555
- path.replace(/\[0\]\./, `.${lang}.`)
563
+ path.replace(/\[0\]\./, `.${lang}.`)?.replace("create", "")
556
564
  );
557
565
  }
558
566
 
@@ -1115,7 +1123,9 @@ const validateField = (
1115
1123
  if (
1116
1124
  onlyFormFields == true &&
1117
1125
  value === undefined &&
1118
- field?.meta?.interface !== constants.interfaces.SEO
1126
+ ![constants.interfaces.TRANSLATIONS, constants.interfaces.SEO].includes(
1127
+ field?.meta?.interface
1128
+ )
1119
1129
  )
1120
1130
  return;
1121
1131
 
@@ -1347,6 +1357,14 @@ const validate = (data) => {
1347
1357
  if (data.onlyFormFields === undefined) {
1348
1358
  data.onlyFormFields = false;
1349
1359
  }
1360
+
1361
+ const refFields = [
1362
+ "created_by",
1363
+ "updated_by",
1364
+ "nox_created_by",
1365
+ "nox_updated_by",
1366
+ ];
1367
+
1350
1368
  let {
1351
1369
  formData,
1352
1370
  isSeparatedFields,
@@ -1363,6 +1381,7 @@ const validate = (data) => {
1363
1381
  existingForm = {},
1364
1382
  timeZone = Intl.DateTimeFormat().resolvedOptions().timeZone,
1365
1383
  } = data;
1384
+ byPassKeys = [...refFields, ...byPassKeys];
1366
1385
 
1367
1386
  const error_messages =
1368
1387
  constants.LOCALE_MESSAGES[language] ??
@@ -1561,6 +1580,8 @@ const validate = (data) => {
1561
1580
 
1562
1581
  // Validate Parameters END
1563
1582
 
1583
+ fields = fields.filter((field) => !refFields.includes(field?.field));
1584
+
1564
1585
  // Get Relational Field
1565
1586
  let schemaFields = fields;
1566
1587
  let allFields = isSeparatedFields ? [] : fields;