Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

310
Views
Validación de URL de entrada de React Antd

Estoy validando el formato de la url y también estoy enviando una solicitud respaldada si esa url aún no se tomó, y si se tomó, realizo la validación por error, si no se tomó, lo haré correctamente. El problema es cuando lo hago correctamente. caso de que el formato de la URL sea incorrecto, se muestra como si fuera un éxito, sé que tengo que verificar si el formato es correcto y la API devuelve verdadero para que la URL no la tome otro, entonces, ¿cómo puedo obtener el estado actual de la validación antd? Esto es mi código

 [![<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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!