express-form-handler
Version:
A form handler for express, the nodejs framework.
28 lines (21 loc) • 570 B
JavaScript
/**
* @licence MIT
* @author Louis Audeon <louis.audeon@mail.be>
*/
const util = require('util')
const Fieldrule = require('./../fieldrule')
function Minlengthrule (length) {
Fieldrule.call(this)
this.name = 'minlength'
this.length = length
}
util.inherits(Minlengthrule, Fieldrule)
Minlengthrule.prototype.check = function (field) {
if (field.value.length < this.length) {
this.error = `The field ${field.label} required a minimum length of ${this.length}`
return false
}
return true
}
module.exports = exports = Minlengthrule