kanun 1.0.5 → 1.0.6
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 +6 -3
- package/dist/index.js +6 -3
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -2067,11 +2067,12 @@ var Password$1 = class Password$1 extends IRuleContract {
|
|
|
2067
2067
|
* Determine if the validation rule passes.
|
|
2068
2068
|
*/
|
|
2069
2069
|
passes(value, attribute) {
|
|
2070
|
-
const
|
|
2070
|
+
const passwordRules = [
|
|
2071
2071
|
"string",
|
|
2072
2072
|
`min:${this.minLength}`,
|
|
2073
2073
|
...this.customRules
|
|
2074
|
-
]
|
|
2074
|
+
];
|
|
2075
|
+
const validator = new BaseValidator(this.data, { [attribute]: passwordRules }, this.validator.customMessages, this.validator.customAttributes).setLang(this.lang);
|
|
2075
2076
|
if (!validator.validate()) {
|
|
2076
2077
|
const errors = validator.errors().addErrorTypes().get(attribute);
|
|
2077
2078
|
for (const key in errors) this.validator.errors().add(attribute, errors[key]);
|
|
@@ -2299,6 +2300,7 @@ var BaseValidator = class BaseValidator {
|
|
|
2299
2300
|
*/
|
|
2300
2301
|
withContext(context = {}) {
|
|
2301
2302
|
this.context = context;
|
|
2303
|
+
this.addRules(this.initalRules);
|
|
2302
2304
|
return this;
|
|
2303
2305
|
}
|
|
2304
2306
|
/**
|
|
@@ -2549,7 +2551,8 @@ var BaseValidator = class BaseValidator {
|
|
|
2549
2551
|
* Parse the given rules add assign them to the current rules
|
|
2550
2552
|
*/
|
|
2551
2553
|
addRules(rules) {
|
|
2552
|
-
const
|
|
2554
|
+
const availableData = mergeDeep(this.getContext().requestFiles ?? {}, this.data);
|
|
2555
|
+
const response = validationRuleParser.explodeRules(dotify(rules, true), availableData);
|
|
2553
2556
|
this.rules = response.rules;
|
|
2554
2557
|
this.implicitAttributes = response.implicitAttributes;
|
|
2555
2558
|
}
|
package/dist/index.js
CHANGED
|
@@ -2037,11 +2037,12 @@ var Password$1 = class Password$1 extends IRuleContract {
|
|
|
2037
2037
|
* Determine if the validation rule passes.
|
|
2038
2038
|
*/
|
|
2039
2039
|
passes(value, attribute) {
|
|
2040
|
-
const
|
|
2040
|
+
const passwordRules = [
|
|
2041
2041
|
"string",
|
|
2042
2042
|
`min:${this.minLength}`,
|
|
2043
2043
|
...this.customRules
|
|
2044
|
-
]
|
|
2044
|
+
];
|
|
2045
|
+
const validator = new BaseValidator(this.data, { [attribute]: passwordRules }, this.validator.customMessages, this.validator.customAttributes).setLang(this.lang);
|
|
2045
2046
|
if (!validator.validate()) {
|
|
2046
2047
|
const errors = validator.errors().addErrorTypes().get(attribute);
|
|
2047
2048
|
for (const key in errors) this.validator.errors().add(attribute, errors[key]);
|
|
@@ -2269,6 +2270,7 @@ var BaseValidator = class BaseValidator {
|
|
|
2269
2270
|
*/
|
|
2270
2271
|
withContext(context = {}) {
|
|
2271
2272
|
this.context = context;
|
|
2273
|
+
this.addRules(this.initalRules);
|
|
2272
2274
|
return this;
|
|
2273
2275
|
}
|
|
2274
2276
|
/**
|
|
@@ -2519,7 +2521,8 @@ var BaseValidator = class BaseValidator {
|
|
|
2519
2521
|
* Parse the given rules add assign them to the current rules
|
|
2520
2522
|
*/
|
|
2521
2523
|
addRules(rules) {
|
|
2522
|
-
const
|
|
2524
|
+
const availableData = mergeDeep(this.getContext().requestFiles ?? {}, this.data);
|
|
2525
|
+
const response = validationRuleParser.explodeRules(dotify(rules, true), availableData);
|
|
2523
2526
|
this.rules = response.rules;
|
|
2524
2527
|
this.implicitAttributes = response.implicitAttributes;
|
|
2525
2528
|
}
|