joi-tz
v5.0.0
Published
Timezone string validation for Joi 16.x or higher.
Downloads
10,111
Maintainers
Readme
joi-tz - Joi Timezone Validation
Provides a Joi rule to validate IANA timezone strings (eg. Europe/London
, America/New_York
, Etc/GMT-8
) using luxon.
Joi-tz supports and is tested against Joi 16.x or higher.
This project is forked from joi-timezone (unmaintained). That project remains functional for Joi 9.x-15.x.
Installation:
npm: npm install joi-tz
yarn: yarn add joi-tz
Usage
import BaseJoi from 'joi';
import JoiTimezone from 'joi-tz';
const Joi = BaseJoi.extend(JoiTimezone);
Joi.timezone().validate('Melbourne/Australia');
// returns {error: null, value: 'Melbourne/Australia'}
Compatibility
This library is tested for compatibility, and contains peer dependencies with the following versions.
| Version | @hapi/joi 16.x | joi 16.x | joi 17.x | |----------------------------------------------------------------|----------------|----------|----------| | 5.0.0 | | ✅ | ✅ | | 4.1.1 | | ✅ | ✅ | | 4.1.0 | | ✅ | ✅ | | 4.0.2 | ✅ | | |