kanun 1.0.6 → 1.0.8

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/dist/index.cjs CHANGED
@@ -1470,8 +1470,9 @@ var validateAttributes = class {
1470
1470
  }
1471
1471
  getAttributeValue(attribute) {
1472
1472
  const dataValue = deepFind(this.data, attribute);
1473
- if (typeof dataValue !== "undefined") return dataValue;
1474
- return deepFind(this.context.requestFiles ?? {}, attribute);
1473
+ const fileValue = deepFind(this.context.requestFiles ?? {}, attribute);
1474
+ if (typeof fileValue !== "undefined" && (typeof dataValue === "undefined" || dataValue === null || dataValue === "")) return fileValue;
1475
+ return dataValue;
1475
1476
  }
1476
1477
  getDistinctValues(primaryAttribute) {
1477
1478
  const gathered = validationData.initializeAndGatherData(primaryAttribute, this.data);
@@ -2300,7 +2301,6 @@ var BaseValidator = class BaseValidator {
2300
2301
  */
2301
2302
  withContext(context = {}) {
2302
2303
  this.context = context;
2303
- this.addRules(this.initalRules);
2304
2304
  return this;
2305
2305
  }
2306
2306
  /**
@@ -2551,8 +2551,7 @@ var BaseValidator = class BaseValidator {
2551
2551
  * Parse the given rules add assign them to the current rules
2552
2552
  */
2553
2553
  addRules(rules) {
2554
- const availableData = mergeDeep(this.getContext().requestFiles ?? {}, this.data);
2555
- const response = validationRuleParser.explodeRules(dotify(rules, true), availableData);
2554
+ const response = validationRuleParser.explodeRules(dotify(rules, true), this.data);
2556
2555
  this.rules = response.rules;
2557
2556
  this.implicitAttributes = response.implicitAttributes;
2558
2557
  }
package/dist/index.js CHANGED
@@ -1440,8 +1440,9 @@ var validateAttributes = class {
1440
1440
  }
1441
1441
  getAttributeValue(attribute) {
1442
1442
  const dataValue = deepFind(this.data, attribute);
1443
- if (typeof dataValue !== "undefined") return dataValue;
1444
- return deepFind(this.context.requestFiles ?? {}, attribute);
1443
+ const fileValue = deepFind(this.context.requestFiles ?? {}, attribute);
1444
+ if (typeof fileValue !== "undefined" && (typeof dataValue === "undefined" || dataValue === null || dataValue === "")) return fileValue;
1445
+ return dataValue;
1445
1446
  }
1446
1447
  getDistinctValues(primaryAttribute) {
1447
1448
  const gathered = validationData.initializeAndGatherData(primaryAttribute, this.data);
@@ -2270,7 +2271,6 @@ var BaseValidator = class BaseValidator {
2270
2271
  */
2271
2272
  withContext(context = {}) {
2272
2273
  this.context = context;
2273
- this.addRules(this.initalRules);
2274
2274
  return this;
2275
2275
  }
2276
2276
  /**
@@ -2521,8 +2521,7 @@ var BaseValidator = class BaseValidator {
2521
2521
  * Parse the given rules add assign them to the current rules
2522
2522
  */
2523
2523
  addRules(rules) {
2524
- const availableData = mergeDeep(this.getContext().requestFiles ?? {}, this.data);
2525
- const response = validationRuleParser.explodeRules(dotify(rules, true), availableData);
2524
+ const response = validationRuleParser.explodeRules(dotify(rules, true), this.data);
2526
2525
  this.rules = response.rules;
2527
2526
  this.implicitAttributes = response.implicitAttributes;
2528
2527
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kanun",
3
- "version": "1.0.6",
3
+ "version": "1.0.8",
4
4
  "description": "Framework-agnostic TypeScript-first validation library.",
5
5
  "type": "module",
6
6
  "files": [