'How to validate data before calling onSubmit in React Hook Form?
I would simply like to validate the data on onChange. Here I have tried using rules prop from Controller but It validate data onSubmit. How can I call my position method every time there's a change in this combobox field?
<Controller
control={control}
name={`${id}_${item.item_id}`}
rules={{
validate: {
positive: (data) => {
console.log(data);
return false;
},
},
}}
render={({ field }) => {
return (
<EuiComboBox
options={itemsOptions}
placeholder="Select Item"
isClearable={true}
singleSelection={true}
selectedOptions={field.value}
onChange={field.onChange}
/>
);
}}
/>;
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
