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

225
Views
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
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!