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

353
Vistas
Yup validation is not working for nested objects for date keys if we have same name

I have used the YUP validation. I need to add validation of startDate and endDate from parent under milestones.

export const validationSchema = Yup.object().shape(
  {
    name: requiredString,
    startDate: Yup.date()
      .nullable()
      .when('endDate', {
        is: (val) => val,
        then: Yup.date().nullable().max(Yup.ref('endDate'), 'message'),
      }),
    endDate: Yup.date()
      .nullable()
      .when('startDate', {
        is: (val) => val,
        then: Yup.date().nullable().min(Yup.ref('startDate'), 'message'),
      }),
    milestones: Yup.array().of(
      Yup.object().shape(
        {
          name: requiredString,
          startDate: Yup.date()
            .nullable()
            .when('endDate', {
              is: (val) => val,
              then: Yup.date().nullable().max(Yup.ref('endDate'), 'message'),
            }),
          endDate: Yup.date()
            .nullable()
            .when('startDate', {
              is: (val) => val,
              then: Yup.date().nullable().min(Yup.ref('startDate'), 'message'),
            }),
        },
        [['startDate', 'endDate']]
      )
    ),
  },
  [['startDate', 'endDate']]
);
about 4 years ago · Juan Pablo Isaza
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