joi-timezone
Provides a Joi rule to validate IANA timezone strings using moment-timezone
Usage
Note: requires Joi version >= 9
;; const Joi = BaseJoi; // Create a joi schema using the timezone validator;const schema = Joi;
Results with valid timezone:
Joi;/* { error: null, value: "Melbourne/Australia" } */
Results with valid timezone returning a moment object:
Joi;/* { error: null, value: { ...moment object } } */
Results with invalid timezone:
Joi;/*{ error: { [ValidationError: "value" timezone failure] isJoi: true, name: 'ValidationError', details: [{ message: '"value" timezone failure', path: 'value', type: 'string.timezone', context: { v: 'Some rubbish', key: 'value' } }], ... }, value: 'Some rubbish'} */