UNPKG

@polyn/blueprint

Version:

An easy to use, flexible, and powerful validation library for nodejs and browsers

15 lines (12 loc) 365 B
module.exports = { name: 'registerExpressions', factory: (Blueprint) => { 'use strict' const { registerValidator } = Blueprint registerValidator('expression', (regex) => ({ key, value }) => { return regex.test(value) === true ? { value } : { err: new Error(`expected \`${key}\` to match ${regex.toString()}`) } }) }, }