express-form-handler
Version:
A form handler for express, the nodejs framework.
29 lines (22 loc) • 583 B
JavaScript
/**
* @licence MIT
* @author Louis Audeon <louis.audeon@mail.be>
*/
const util = require('util')
const validator = require('validator')
const Fieldformat = require('./../fieldformat')
function Integerformat () {
Fieldformat.call(this)
this.name = 'integer'
this.error = null
}
util.inherits(Integerformat, Fieldformat)
Integerformat.prototype.check = function (field) {
if (!validator.isInt(field.value + '')) {
this.error = `The field ${field.label} must be an integer`
return false
}
return true
}
module.exports = exports = Integerformat