New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

joi-bcp47

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

joi-bcp47

IETF BCP47 language tag validation for Joi.

  • 1.1.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
4
Maintainers
1
Weekly downloads
 
Created
Source

joi-bcp47 - Joi BCP47 IETF Language Tag Validation

Build Status Coverage Status Known Vulnerabilities npm version FOSSA Status

Provides a Joi rule to validate and parse BCP47 language tags (eg. en-US, ur-PK, zh-Hant-TW).

Note: Only supports Joi 16.x or higher. Does not validate the components of the BCP47 tag (eg. language or region codes), only the structure and syntax.

Installation:

npm: npm install joi-bcp47

yarn: yarn add joi-bcp47

Usage

import BaseJoi from 'joi';
import JoiBcp47 from 'joi-bcp47';

const Joi = BaseJoi.extend(JoiBcp47);

Joi.bcp47().validate('en-US');
// returns {error: null, value: 'en-US'}

Rules

parse - Parse the BCP47 tag into an object

When added to the validation chain returns a bcp47 parse object which parses the BCP47 tag out to its individual components.

Joi.bcp47().parse().validate('hy-Latn-IT-arevela');
/*
    returns {
        error: null,
        value: {
            langtag: {
                language: {
                    language: "hy",
                    extlang: []
                },
                script: "Latn",
                region: "IT",
                variant: ["arevela"],
                extension: [],
                privateuse: []
            },
            privateuse: [],
            grandfathered: {
                irregular: null,
                regular: null
            }
        }
    }
*/

Compatibility

This library is tested for compatibility, and contains peer dependencies with the following versions.

Version@hapi/joi 16.xjoi 16.xjoi 17.x
1.1.0
1.0.0

License

FOSSA Status

Keywords

FAQs

Package last updated on 06 Sep 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc