joi-timezone
Provides a Joi rule to validate IANA timezone strings using moment-timezone
Usage
Note: requires Joi version >= 9
import BaseJoi from 'joi';
import JoiTimezone from 'joi-timezone';
const Joi = BaseJoi.extend(JoiTimezone);
const schema = Joi.string().timezone();
Results with valid timezone:
Joi.validate("Melbourne/Australia", Joi.string().timezone());
Results with valid timezone returning a moment object:
Joi.validate("Melbourne/Australia", Joi.string().timezone({returnMoment: true}));
Results with invalid timezone:
Joi.validate("Some rubbish", Joi.string().timezone());