UNPKG

async-validate

Version:

Asynchronous validation for node and the browser

13 lines (11 loc) 242 B
function id(cb) { var re = /^[^-][a-zA-Z0-9-]+$/; if(!re.test(this.value)) { this.raise('%s is not a valid identifier', this.field); } cb(); } module.exports = function() { // add static `id` type method this.main.id = id; }