react-mui-form-validator 1.5.0 → 1.5.1
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/Readme.md +1 -0
- package/lib/index.js +25 -30
- package/package.json +1 -1
package/Readme.md
CHANGED
package/lib/index.js
CHANGED
|
@@ -17617,42 +17617,37 @@ var ValidatorComponent = class extends React62.Component {
|
|
|
17617
17617
|
getErrorMessage = () => {
|
|
17618
17618
|
const { errorMessages } = this.state;
|
|
17619
17619
|
const type = typeof errorMessages;
|
|
17620
|
-
if (
|
|
17621
|
-
|
|
17622
|
-
|
|
17623
|
-
|
|
17624
|
-
|
|
17625
|
-
return errorMessages[this.invalid[0]];
|
|
17626
|
-
}
|
|
17620
|
+
if (type === "string") {
|
|
17621
|
+
return errorMessages;
|
|
17622
|
+
} else if (type === "object") {
|
|
17623
|
+
if (this.invalid.length > 0) {
|
|
17624
|
+
return errorMessages[this.invalid[0]];
|
|
17627
17625
|
}
|
|
17628
17626
|
}
|
|
17629
17627
|
return true;
|
|
17630
17628
|
};
|
|
17631
17629
|
validate = async (value, dryRun = false) => {
|
|
17632
|
-
|
|
17633
|
-
|
|
17634
|
-
|
|
17635
|
-
|
|
17636
|
-
|
|
17637
|
-
|
|
17638
|
-
|
|
17639
|
-
|
|
17640
|
-
|
|
17641
|
-
|
|
17642
|
-
|
|
17643
|
-
|
|
17644
|
-
valid = false;
|
|
17645
|
-
this.invalid.push(key);
|
|
17646
|
-
}
|
|
17647
|
-
});
|
|
17648
|
-
if (!dryRun) {
|
|
17649
|
-
this.setState({ isValid: valid }, () => {
|
|
17650
|
-
if (this.props.validatorListener)
|
|
17651
|
-
this.props.validatorListener(
|
|
17652
|
-
this.state.isValid === void 0 ? false : this.state.isValid
|
|
17653
|
-
);
|
|
17654
|
-
});
|
|
17630
|
+
const validations2 = Promise.all(
|
|
17631
|
+
this.state.validators.map(
|
|
17632
|
+
(validator2) => ValidatorForm_default.getValidator(value, validator2)
|
|
17633
|
+
)
|
|
17634
|
+
);
|
|
17635
|
+
const results = await validations2;
|
|
17636
|
+
this.invalid = [];
|
|
17637
|
+
let valid = true;
|
|
17638
|
+
results.forEach((result, key) => {
|
|
17639
|
+
if (!result) {
|
|
17640
|
+
valid = false;
|
|
17641
|
+
this.invalid.push(key);
|
|
17655
17642
|
}
|
|
17643
|
+
});
|
|
17644
|
+
if (!dryRun) {
|
|
17645
|
+
this.setState({ isValid: valid }, () => {
|
|
17646
|
+
if (this.props.validatorListener)
|
|
17647
|
+
this.props.validatorListener(
|
|
17648
|
+
this.state.isValid === void 0 ? false : this.state.isValid
|
|
17649
|
+
);
|
|
17650
|
+
});
|
|
17656
17651
|
}
|
|
17657
17652
|
return valid;
|
|
17658
17653
|
};
|