Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

307
Visualizações
React Antd Input url validation

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]
about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda