- Joined
- Dec 2, 2022
- Messages
- 7
- Reaction score
- 1
Hi!
I use Formik+Yup for my forms. I have this validation scheme that checks the domain entered by the user for correctness, and also by sending this domain to the API to check if it is on cloudflare:
How can I trigger a domain verification request in API only after it has passed other validations, but not in parallel?
I use Formik+Yup for my forms. I have this validation scheme that checks the domain entered by the user for correctness, and also by sending this domain to the API to check if it is on cloudflare:
JavaScript:
const validationSchema = Yup.object().shape({
domainName: Yup.string()
.required('The website URL is required')
.matches(URL_REGEX, 'Enter correct URL')
.test('is-on-cloudflare', 'Invalid domain name', async (domainName: string) => {
const re = /^https?:\/\//
if (re.test(domainName)) {
const res = await checkCloudflareStatus(domainName)
if (res.data?.on_cloudflare) {
return true
}
}
return false
}),
})
How can I trigger a domain verification request in API only after it has passed other validations, but not in parallel?