Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

132
Vistas
Ant design Form "Warning: `callback` is deprecated. Please return a promise instead." Error in custom rules

I made custom rule on form elements. But when i use custom error message with promise its giving that error. What should i do for fix it ? My Form elements :

That rule is checking PriceMax and PriceMin. And validate if PriceMax is bigger than PriceMin. If Its not it should show me error message.So i used Promise but it making warning in console like : "Warning: callback is deprecated. Please return a promise instead." Error in custom rules"

 <Form.Item name="PriceMin" label="Minimum fiyat" required>
                  <Input
                    type="number"
                    name="Input"
                    placeholder="En düşük fiyat"
                    onChange={(e) => updateForm(e.target.value, "PriceMin")}
                  />
                </Form.Item>
                <Form.Item
                  name="PriceMax"
                  label="Maximum fiyat"
                  dependencies={["PriceMin"]}
                  rules={[
                    {
                      required: true,
                      message: "Please confirm your password!",
                    },
                    ({ getFieldValue }) => ({
                      validator(rule, value) {
                        if (
                          parseInt(value) < parseInt(getFieldValue("PriceMin"))
                        ) {
                          return Promise.reject(
                            "Maksimum fiyat minimum fiyattan az olamaz!"  //When i delete that row its fix warning, but i need have that error message.
                          );
                        }
                      },
                    }),
                  ]}
                >
                  <Input
                    name="Input"
                    type="number"
                    disabled={
                      MyForm.getFieldValue("PriceMin") === undefined ||
                      MyForm.getFieldValue("PriceMin") === ""
                        ? true
                        : false
                    }
                    placeholder="En yüksek fiyat"
                    onChange={(e) => updateForm(e.target.value, "PriceMax")}
                  />
                </Form.Item>
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

You must do as shown in the example
https://ant.design/components/form/#components-form-demo-register
The validator should always return a promise on both success and error

({ getFieldValue }) => ({
    validator(rule, value) {
        if (parseInt(value, 10) < parseInt(getFieldValue("PriceMin"), 10)) {
            return Promise.reject(
                  "Maksimum fiyat minimum fiyattan az olamaz!");
        }
        return Promise.resolve();
    }
})

Also you missed a radix parameter in the parseInt

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda