Skip to content

socketkit/ajv-locale-code

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ajv-locale-code

Adds a locale_code format to Ajv.

Install

npm i --save @socketkit/ajv-locale-code

Setup

import Ajv from 'ajv'
import localeCode from '@socketkit/ajv-locale-code'
const ajv = new Ajv()
localeCode(ajv)

Usage

When defining your JSON schema, use the format keyword with ther value set to locale_code. For example

{
  "type": "object",
  "properties": {
    "locale": {
      "type": "string",
      "format": "locale_code"
    }
  }
}

About

Ajv plugin for validating ISO-639-1 and ISO-3166-1 input types

Resources

Stars

Watchers

Forks

Packages

No packages published