well-known-regex

0.1.1 • Public • Published

well-known-regex

Get deeper type hints from validators using regex.

There are many libraries of regex functions for the purpose of validation, and while this library does serve this purpose, it's real purpose is one of recognition: It can classify a given field set and even generate coherent values for them.

All field values follow the structure of faker (currently implemented: name.*, address.*, internet.*)

Usage

const { WKR, classifyRegex, generateData } = require('well-known-regex');
let classified = classify({
    properties : {
        name : { pattern: WKR.internet.username.pattern },
        email : { pattern: WKR.internet.email.pattern }
    }
}, {locale: 'en_us'});

/*
classified => {
    name : 'user.username',
    email : 'user.email'
}
*/

let generated = generateData({
    properties : {
        name : { pattern: WKR.internet.username.pattern },
        email : { pattern: WKR.internet.email.pattern }
    }
}, {locale: 'en_us', seed: 'some_value'});

/well-known-regex/

    Package Sidebar

    Install

    npm i well-known-regex

    Weekly Downloads

    6

    Version

    0.1.1

    License

    none

    Unpacked Size

    47.3 kB

    Total Files

    12

    Last publish

    Collaborators

    • khrome