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

224
Views
Sí validación basada en objeto anidado dentro de objeto anidado

Actualmente tengo un objeto que se parece a lo siguiente:

 const initialValues = { created: { position: 1, name: 'created', type: 'timestamp', desc: 'The date and time the lead is created', mapping: { name: '', defaultValue: '', map: false } } }

Me gustaría que el nombre dentro del objeto de mapeo sea obligatorio cuando el valor del mapa dentro del objeto del mapa se establece en un valor de verdadero. He intentado esto haciendo lo siguiente:

 const validationSchema = yup.object({ created: yup.object().when('mapping.map', { is: true, then: yup.object({ mapping: yup.object({ name: yup.string().required('name is required') }) }) }) })

Creo que no estoy haciendo un túnel lo suficiente para configurar con precisión la validación del objeto de mapeo, cualquier ayuda/sugerencia sería muy apreciada.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Encontré la solución haciendo lo siguiente:

 const validationSchema = yup.object({ created: yup.object().shape({ mapping: yup.object().shape({ map: yup.boolean(), defaultValue: yup.string(), name: yup.string().when('map', { is: true, then: yup.string().required('name is required') }) }) }) })
about 4 years ago · Juan Pablo Isaza Report
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!