nox-validation 1.0.3 → 1.0.5

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/helpers.js +6 -5
  2. package/package.json +1 -1
package/lib/helpers.js CHANGED
@@ -192,6 +192,7 @@ const convertTypes = (field) => {
192
192
  constants.interfaces.ONE_TO_MANY,
193
193
  constants.interfaces.MANY_TO_MANY,
194
194
  constants.interfaces.MANY_TO_ANY,
195
+ constants.interfaces.MANY_TO_ONE,
195
196
  constants.interfaces.TRANSLATIONS,
196
197
  ].includes(interfaceType)
197
198
  ) {
@@ -503,7 +504,7 @@ const getForeignCollectionDetails = ({
503
504
 
504
505
  if (isSingleRelation) {
505
506
  const mainTable = relations.find(
506
- (d) => d.many_collection_id === collection && d.many_field === field
507
+ (d) => d.many_collection_id === collection && d.many_field_id === field
507
508
  );
508
509
  if (!mainTable) return {};
509
510
 
@@ -591,7 +592,6 @@ const buildNestedStructure = (
591
592
 
592
593
  const definedType =
593
594
  apiVersion === constants.API_VERSION.V1 ? convertTypesV1(item) : convertTypes(item);
594
-
595
595
  if (definedType.find_relations) {
596
596
  const relationDetail = getForeignCollectionDetails({
597
597
  relations: relations,
@@ -612,8 +612,9 @@ const buildNestedStructure = (
612
612
  } else {
613
613
  childFields = getCachedFields(relationDetail, relational_fields);
614
614
  }
615
+ const isUserKey = item?.path?.includes("updated_by") || item?.path?.includes("created_by");
615
616
 
616
- if (childFields) {
617
+ if (childFields && !isUserKey) {
617
618
  childFields = buildNestedStructure(
618
619
  childFields,
619
620
  allFields,
@@ -821,14 +822,14 @@ const generateFieldCompareRules = (rule) => {
821
822
  return modifiedRule;
822
823
  };
823
824
 
824
- const generateModifiedRules = (meta,custom_message) => {
825
+ const generateModifiedRules = (meta, custom_message) => {
825
826
  return meta?.validations?.rules?.map((rule, index) => {
826
827
  let modifiedRule = {
827
828
  identifier: String(index),
828
829
  case: constants.rulesTypes.RULES_COMPARE,
829
830
  value: [],
830
831
  options: {},
831
- custom_message
832
+ custom_message,
832
833
  };
833
834
  switch (rule.rule) {
834
835
  case "contains":
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nox-validation",
3
- "version": "1.0.3",
3
+ "version": "1.0.5",
4
4
  "description": "validate dynamic schema",
5
5
  "main": "index.js",
6
6
  "scripts": {