bcp47-validate

1.0.0 • Public • Published

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

Package Sidebar

Install

npm i bcp47-validate

Weekly Downloads

3,196

Version

1.0.0

License

Apache-2.0

Last publish

Collaborators

  • tjdavey