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

117
Views
Validating time zone in a Joi schema

I want to accept a request that sends several query parameters with it and I am validating it using Joi library in Nodejs/Express but can't figure out how to validate time zone values(which is one of the query parameters?

function validateLedger(ledger){
    let schema=Joi.object({
    startDate:Joi.date().iso(),
    endDate:Joi.date().iso().greater(Joi.ref('startDate')),
    paymentFrequency:Joi.string().valid('weekly','fortnightly','monthly'),
    weeklyRate:Joi.number().greater(0),
    timeZone://this needs to be validated
    });

    return schema.validate(ledger)
}
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

I just used joi-tz please find the code below

const Joi=require('joi')
const JoiTimezone=require('joi-tz')
const JoiTZ = Joi.extend(JoiTimezone);

function validateLedger(ledger){
    let schema=Joi.object({
    startDate:Joi.date().iso(),
    endDate:Joi.date().iso().greater(Joi.ref('startDate')),
    paymentFrequency:Joi.string().valid('weekly','fortnightly','monthly'),
    weeklyRate:Joi.number().greater(0),
    timeZone:JoiTZ.timezone().required()//the answer
    });

    return schema.validate(ledger)
}
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!