kanun 1.0.7 → 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 +3 -11
- package/dist/index.d.ts +0 -5
- package/dist/index.js +3 -11
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -2301,7 +2301,6 @@ var BaseValidator = class BaseValidator {
|
|
|
2301
2301
|
*/
|
|
2302
2302
|
withContext(context = {}) {
|
|
2303
2303
|
this.context = context;
|
|
2304
|
-
this.addRules(this.initalRules);
|
|
2305
2304
|
return this;
|
|
2306
2305
|
}
|
|
2307
2306
|
/**
|
|
@@ -2552,8 +2551,7 @@ var BaseValidator = class BaseValidator {
|
|
|
2552
2551
|
* Parse the given rules add assign them to the current rules
|
|
2553
2552
|
*/
|
|
2554
2553
|
addRules(rules) {
|
|
2555
|
-
const
|
|
2556
|
-
const response = validationRuleParser.explodeRules(dotify(rules, true), availableData);
|
|
2554
|
+
const response = validationRuleParser.explodeRules(dotify(rules, true), this.data);
|
|
2557
2555
|
this.rules = response.rules;
|
|
2558
2556
|
this.implicitAttributes = response.implicitAttributes;
|
|
2559
2557
|
}
|
|
@@ -2660,17 +2658,11 @@ var BaseValidator = class BaseValidator {
|
|
|
2660
2658
|
}
|
|
2661
2659
|
/**
|
|
2662
2660
|
* Resolve an attribute value from validator data first, then request-scoped file context.
|
|
2663
|
-
* When the data value is empty (null or empty string), prefer a file from requestFiles
|
|
2664
|
-
* because framework body-parsers commonly set file input fields to '' or null.
|
|
2665
|
-
*
|
|
2666
|
-
* @param attribute
|
|
2667
|
-
* @returns
|
|
2668
2661
|
*/
|
|
2669
2662
|
getAttributeValue(attribute) {
|
|
2670
2663
|
const dataValue = deepFind(this.data, attribute);
|
|
2671
|
-
|
|
2672
|
-
|
|
2673
|
-
return dataValue;
|
|
2664
|
+
if (typeof dataValue !== "undefined") return dataValue;
|
|
2665
|
+
return deepFind(this.getContext().requestFiles ?? {}, attribute);
|
|
2674
2666
|
}
|
|
2675
2667
|
/**
|
|
2676
2668
|
* Get the primary attribute name
|
package/dist/index.d.ts
CHANGED
|
@@ -610,11 +610,6 @@ declare class BaseValidator<D extends GenericObject = GenericObject> {
|
|
|
610
610
|
private isNotNullIfMarkedAsNullable;
|
|
611
611
|
/**
|
|
612
612
|
* Resolve an attribute value from validator data first, then request-scoped file context.
|
|
613
|
-
* When the data value is empty (null or empty string), prefer a file from requestFiles
|
|
614
|
-
* because framework body-parsers commonly set file input fields to '' or null.
|
|
615
|
-
*
|
|
616
|
-
* @param attribute
|
|
617
|
-
* @returns
|
|
618
613
|
*/
|
|
619
614
|
private getAttributeValue;
|
|
620
615
|
/**
|
package/dist/index.js
CHANGED
|
@@ -2271,7 +2271,6 @@ var BaseValidator = class BaseValidator {
|
|
|
2271
2271
|
*/
|
|
2272
2272
|
withContext(context = {}) {
|
|
2273
2273
|
this.context = context;
|
|
2274
|
-
this.addRules(this.initalRules);
|
|
2275
2274
|
return this;
|
|
2276
2275
|
}
|
|
2277
2276
|
/**
|
|
@@ -2522,8 +2521,7 @@ var BaseValidator = class BaseValidator {
|
|
|
2522
2521
|
* Parse the given rules add assign them to the current rules
|
|
2523
2522
|
*/
|
|
2524
2523
|
addRules(rules) {
|
|
2525
|
-
const
|
|
2526
|
-
const response = validationRuleParser.explodeRules(dotify(rules, true), availableData);
|
|
2524
|
+
const response = validationRuleParser.explodeRules(dotify(rules, true), this.data);
|
|
2527
2525
|
this.rules = response.rules;
|
|
2528
2526
|
this.implicitAttributes = response.implicitAttributes;
|
|
2529
2527
|
}
|
|
@@ -2630,17 +2628,11 @@ var BaseValidator = class BaseValidator {
|
|
|
2630
2628
|
}
|
|
2631
2629
|
/**
|
|
2632
2630
|
* Resolve an attribute value from validator data first, then request-scoped file context.
|
|
2633
|
-
* When the data value is empty (null or empty string), prefer a file from requestFiles
|
|
2634
|
-
* because framework body-parsers commonly set file input fields to '' or null.
|
|
2635
|
-
*
|
|
2636
|
-
* @param attribute
|
|
2637
|
-
* @returns
|
|
2638
2631
|
*/
|
|
2639
2632
|
getAttributeValue(attribute) {
|
|
2640
2633
|
const dataValue = deepFind(this.data, attribute);
|
|
2641
|
-
|
|
2642
|
-
|
|
2643
|
-
return dataValue;
|
|
2634
|
+
if (typeof dataValue !== "undefined") return dataValue;
|
|
2635
|
+
return deepFind(this.getContext().requestFiles ?? {}, attribute);
|
|
2644
2636
|
}
|
|
2645
2637
|
/**
|
|
2646
2638
|
* Get the primary attribute name
|