1.0.0 • Published 7 years ago

bcp47-validate v1.0.0

Weekly downloads
1,325
License
Apache-2.0
Repository
github
Last release
7 years ago

bcp47

Build Status Coverage Status

Simple validator for BCP47 locale tags

Helpful resources:

Usage

Install

$ npm i @safetyculture/bcp47 --save

Importing

import {validate, pattern} from 'bcp47';

Properties

pattern

A regular expression for validating locale strings

// use with third party validation tools
Joi.string().regex(pattern)

// or just regex
pattern.test(locale);

Methods

validate(locale) => Boolean

Validate a given locale string.

  • locale. Example en-US
validate('en-US'); // true
validate('en_US'); // false