feat: validate plain fields on blur (#3922)
This commit is contained in:
parent
822819f42a
commit
8d2d5d5f2c
@ -97,11 +97,15 @@ export default class Widget extends Component {
|
|||||||
this.wrappedControlShouldComponentUpdate = scu && scu.bind(this.innerWrappedControl);
|
this.wrappedControlShouldComponentUpdate = scu && scu.bind(this.innerWrappedControl);
|
||||||
};
|
};
|
||||||
|
|
||||||
validate = (skipWrapped = false) => {
|
getValidateValue = () => {
|
||||||
let value = this.innerWrappedControl?.getValidateValue?.() || this.props.value;
|
let value = this.innerWrappedControl?.getValidateValue?.() || this.props.value;
|
||||||
// Convert list input widget value to string for validation test
|
// Convert list input widget value to string for validation test
|
||||||
List.isList(value) && (value = value.join(','));
|
List.isList(value) && (value = value.join(','));
|
||||||
|
return value;
|
||||||
|
};
|
||||||
|
|
||||||
|
validate = (skipWrapped = false) => {
|
||||||
|
const value = this.getValidateValue();
|
||||||
const field = this.props.field;
|
const field = this.props.field;
|
||||||
const errors = [];
|
const errors = [];
|
||||||
const validations = [this.validatePresence, this.validatePattern];
|
const validations = [this.validatePresence, this.validatePattern];
|
||||||
@ -224,6 +228,13 @@ export default class Widget extends Component {
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
setInactiveStyle = () => {
|
||||||
|
this.props.setInactiveStyle();
|
||||||
|
if (this.props.field.has('pattern') && !isEmpty(this.getValidateValue())) {
|
||||||
|
this.validate();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const {
|
const {
|
||||||
controlComponent,
|
controlComponent,
|
||||||
@ -248,7 +259,6 @@ export default class Widget extends Component {
|
|||||||
classNameLabel,
|
classNameLabel,
|
||||||
classNameLabelActive,
|
classNameLabelActive,
|
||||||
setActiveStyle,
|
setActiveStyle,
|
||||||
setInactiveStyle,
|
|
||||||
hasActiveStyle,
|
hasActiveStyle,
|
||||||
editorControl,
|
editorControl,
|
||||||
uniqueFieldId,
|
uniqueFieldId,
|
||||||
@ -294,7 +304,7 @@ export default class Widget extends Component {
|
|||||||
classNameLabel,
|
classNameLabel,
|
||||||
classNameLabelActive,
|
classNameLabelActive,
|
||||||
setActiveStyle,
|
setActiveStyle,
|
||||||
setInactiveStyle,
|
setInactiveStyle: () => this.setInactiveStyle(),
|
||||||
hasActiveStyle,
|
hasActiveStyle,
|
||||||
editorControl,
|
editorControl,
|
||||||
resolveWidget,
|
resolveWidget,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user