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