nox-validation 1.3.5 → 1.3.7

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
@@ -374,6 +374,16 @@ const generateRelationalField = (
374
374
  constants.types.NUMBER,
375
375
  constants.types.NUMBER
376
376
  ),
377
+ generateField(
378
+ "collection_id",
379
+ `${key}.existing.collection_id`,
380
+ constants.types.OBJECT_ID,
381
+ constants.types.OBJECT_ID,
382
+ [],
383
+ "none",
384
+ [],
385
+ collection_id_meta
386
+ ),
377
387
  generateField(
378
388
  "item",
379
389
  `${key}.existing.item`,
@@ -400,6 +410,16 @@ const generateRelationalField = (
400
410
  constants.types.NUMBER,
401
411
  constants.types.NUMBER
402
412
  ),
413
+ generateField(
414
+ "collection_id",
415
+ `${key}.delete.collection_id`,
416
+ constants.types.OBJECT_ID,
417
+ constants.types.OBJECT_ID,
418
+ [],
419
+ "none",
420
+ [],
421
+ collection_id_meta
422
+ ),
403
423
  generateField(
404
424
  "item",
405
425
  `${key}.delete.item`,
@@ -422,7 +442,7 @@ const generateRelationalField = (
422
442
  constants.types.STRING
423
443
  ),
424
444
  generateField(
425
- "collection",
445
+ "collection_id",
426
446
  `${key}.create.collection_id`,
427
447
  constants.types.OBJECT_ID,
428
448
  constants.types.OBJECT_ID,
@@ -442,7 +462,7 @@ const generateRelationalField = (
442
462
  `${key}.create.item`,
443
463
  constants.types.OBJECT,
444
464
  constants.types.OBJECT,
445
- collectionFields,
465
+ [...collectionFields],
446
466
  "none",
447
467
  [constants.types.OBJECT_ID],
448
468
  { ...collection_id_meta, is_m2a_item: true }
@@ -463,7 +483,7 @@ const generateRelationalField = (
463
483
  constants.types.STRING
464
484
  ),
465
485
  generateField(
466
- "collection",
486
+ "collection_id",
467
487
  `${key}.update.collection_id`,
468
488
  constants.types.OBJECT_ID,
469
489
  constants.types.OBJECT_ID,
@@ -483,9 +503,10 @@ const generateRelationalField = (
483
503
  `${key}.update.item`,
484
504
  constants.types.OBJECT,
485
505
  constants.types.OBJECT,
486
- collectionFields,
506
+ [...collectionFields],
487
507
  "none",
488
- [constants.types.OBJECT_ID]
508
+ [constants.types.OBJECT_ID],
509
+ { ...collection_id_meta, is_m2a_item: true }
489
510
  ),
490
511
  ];
491
512
  return [existingField, deleteField, createField, updateField];
@@ -757,6 +778,14 @@ const buildNestedStructure = ({
757
778
  } else {
758
779
  childFields = getCachedFields(relationDetail, relational_fields);
759
780
  }
781
+ if(item.meta.interface === constants.interfaces.TRANSLATIONS){
782
+ childFields = childFields.filter(
783
+ (f) =>
784
+ f.field !== relationDetail.foreign_field &&
785
+ f.field !== relationDetail.junction_field_this &&
786
+ f.field !== relationDetail.junction_field_foreign
787
+ );
788
+ }
760
789
 
761
790
  if (childFields) {
762
791
  if (!isRoot) currentDepthMap.set(rootPath, currentDepth + 1);
package/lib/validate.js CHANGED
@@ -284,6 +284,7 @@ const validateMetaRules = (
284
284
  constants.interfaces.ONE_TO_MANY,
285
285
  constants.interfaces.MANY_TO_ONE,
286
286
  constants.interfaces.MANY_TO_ANY,
287
+ "none"
287
288
  ].includes(field?.meta?.interface)
288
289
  ) {
289
290
  const isTranslationChild =
@@ -300,6 +301,9 @@ const validateMetaRules = (
300
301
 
301
302
  if (fPath.includes("update.")) return;
302
303
  if (fPath.includes("create.") && !isTranslationChild) return;
304
+ if (fPath.includes("delete.") && !isTranslationChild) return;
305
+ if (fPath.includes("existing.") && !isTranslationChild) return;
306
+
303
307
 
304
308
  const label = formatLabel(node.display_label);
305
309
  const message = error_messages.REQUIRED.replace("{field}", label);
@@ -812,18 +816,18 @@ const validateField = (
812
816
  typeChecks[constants.types.OBJECT](value)
813
817
  ) {
814
818
  let itemSchemaId = null;
815
-
819
+ let childrenToValidate = field.children
816
820
  if (is_m2a_item) {
817
821
  const fieldPath = getM2AItemParentPath(currentPath);
818
822
  if (fieldPath) {
819
823
  itemSchemaId = getValue(formData, fieldPath)?.collection_id;
824
+ if(!itemSchemaId){
825
+ childrenToValidate = []
826
+ }else{
827
+ childrenToValidate = field.children.filter((child) => child.schema_id === itemSchemaId)
828
+ }
820
829
  }
821
830
  }
822
-
823
- const childrenToValidate = itemSchemaId
824
- ? field.children.filter((child) => child.schema_id === itemSchemaId)
825
- : field.children;
826
-
827
831
  childrenToValidate.forEach((child) =>
828
832
  validateField(
829
833
  child,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nox-validation",
3
- "version": "1.3.5",
3
+ "version": "1.3.7",
4
4
  "description": "validate dynamic schema",
5
5
  "main": "index.js",
6
6
  "scripts": {