khrome / well-known-regex

A Regex library focused on recognition and coherent generation.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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'});

About

A Regex library focused on recognition and coherent generation.


Languages

Language:JavaScript 100.0%