Как написать проверку так, чтобы кнопка ставала активной только тогда, когда номер введен полностью?
import { useForm, Controller } from "react-hook-form"
import PhoneInput from "react-phone-input-2"
import "react-phone-input-2/lib/style.css"
import { yupResolver } from "@hookform/resolvers/yup"
const schema = yup.object().shape({
phone: yup.mixed().test("phone", "Error", value => {
console.log(value)
}),
})
const PhoneForm = () => {
const {
register,
formState: { errors, isValid },
handleSubmit,
control
} = useForm({
mode: "all",
resolver: yupResolver(schema)
})
const onSubmit = data => {
}
return (
<form onSubmit={handleSubmit(onSubmit)}>
<Controller
control={control}
name="phone"
defaultValue=""
render={({ field }) => (
<PhoneInput className="input-control" country={'us'} {...field} />)
}
/>
<Button
disabled={!isValid}
>Go</Button>
</form>
)
}
export default PhoneForm