How to add validation, I want show error message on for phone number field (helperText, min 10 , max 10 ) and also show error message if submitted without 10 numeric digit
import ReactPhoneInput from "react-phone-input-2"
import {TextField,Button}from "@material-ui/core"
const {register, handleSubmit,formState: { errors }} = useForm()
const getData= (data) => {
console.log(data.username)
console.log(data.phone);
}
<form onSubmit={handleSubmit(getData)} >
<Controller
control={control}
name="phone"
render={({ field: { ref, ...field } }) => (
<ReactPhoneInput {...field}
inputExtraProps={{ref, required: true, autoFocus: true }}
country={"in"}
onlyCountries={["in"]}
countryCodeEditable={false}
specialLabel={"Player Mobile Number"}
/>
)}
/>
<Button type='submit>Submit</Button>
</form>