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