nox-validation 1.1.0 → 1.1.2

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
@@ -547,7 +547,7 @@ const getForeignCollectionDetails = ({
547
547
  this_collection: mainTable.one_collection_id,
548
548
  this_field: "_id",
549
549
  foreign_collection:
550
- iFace === constants.interfaces.MANY_TO_MANY || iFace === constants.interfaces.TRANSLATIONS
550
+ iFace === constants.interfaces.MANY_TO_MANY
551
551
  ? relational?.one_collection_id
552
552
  : iFace === constants.interfaces.MANY_TO_ANY
553
553
  ? relational?.one_allowed_collections_id
package/lib/validate.js CHANGED
@@ -681,9 +681,12 @@ const validate = (data) => {
681
681
  language,
682
682
  maxLevel,
683
683
  } = data;
684
- const defaultLanguage = constants.LANGUAGES.length > 0 ? constants.LANGUAGES[0] : "en"; // Replace "en" with your actual default
685
- const error_messages =
686
- constants.LOCALE_MESSAGES[language] ?? constants.LOCALE_MESSAGES[defaultLanguage];
684
+
685
+ if (!data?.language) {
686
+ data.language = constants.LANGUAGES.en;
687
+ }
688
+
689
+ const error_messages = constants.LOCALE_MESSAGES[language];
687
690
 
688
691
  let result = { status: true, errors: {}, data: formData };
689
692
 
@@ -851,7 +854,7 @@ const validate = (data) => {
851
854
  isRoot: true,
852
855
  }) || [];
853
856
 
854
- findDisallowedKeys(formData, fieldOptions,maxLevel).forEach((fieldPath) => {
857
+ findDisallowedKeys(formData, fieldOptions, maxLevel).forEach((fieldPath) => {
855
858
  if (abortEarly && !result.status) return result;
856
859
  const fieldKey = getLastChildKey(fieldPath);
857
860
  if (fieldKey && !result.errors[fieldPath]) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nox-validation",
3
- "version": "1.1.0",
3
+ "version": "1.1.2",
4
4
  "description": "validate dynamic schema",
5
5
  "main": "index.js",
6
6
  "scripts": {