am validation the format of url and also am sending backed request if that url doesn't already taken, and if it is taken i make the validation to error if it is not taken i will make it success the problem is when i make it success event the url format is wrong it shows as it is success, i know i have to check if the format is correct and the api return true for the url not taking by other so how can i get the current status of the antd validation this is my code
[![<Form.Item
name="websiteUrl"
className="max-w-sm"
validateStatus={validationStatus}
hasFeedback
rules={\[
{
required: true,
type: 'url',
message:
'Insert a Valid website URL (make sure to include http/https)',
},
// {
// pattern: new RegExp('^(ftp|http|https)://\[^ "\]+$'),
// },
({ getFieldValue }) => ({
async validator(rule, value) {
if (value === '') {
return setValidationStatus('error');
} else {
setValidationStatus('validating');
await checkWebsiteUrlApi(String(value).trim())
.then((response) => {
if (response) {
setValidationStatus('error');
return Promise.reject(
new Error('URL already exits!')
);
} else {
/* this is causing the problem before is set it to success i also have to check if the url is correct format before setting it to success */
setValidationStatus('success');
return Promise.resolve();
}
})
.catch((error) => {
setValidationStatus('error');
return Promise.reject(new Error(error?.message));
});
}
},
}),
\]}
>
<Input
name="websiteUrl"
defaultValue={websiteUrl}
onChange={(e) => setWebsiteUrl(e.target.value)}
className="max-w-sm"
/>
</Form.Item>][1]][1]