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

227
Vistas
Firestore Schema Validator - Set default value for the nested optional fields

I am using the firestore schema validator to validate the Input to REST API system. I have a input validation schema defined as below:

const userDataSchema = schema({
   field1 : field("field1").integer().default(1000).optional(),
   field2 : field("field2").integer().default(10).optional(),
});

module.exports = {
   testInput : ({
      userName : field("userName").string().trim(),
      userData : field("userData").objectOf(userDataSchema).optional(),
   })
}

userData is an optional field, and if we do not provide the userData field the default values are not getting assigned to field1 and field2. However if I provide userData without any fields the field1 and field2 are assigned with the default values.

Is there a way I can assign the default values to field1 and field2 if we do not pass userData?

Thank you,
KK

Is there a workaround to

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