20 lines
479 B
JavaScript
20 lines
479 B
JavaScript
const Base = require('./base.js')
|
|
const util = require('util')
|
|
|
|
class TypeBoolean extends Base {
|
|
constructor () {
|
|
super()
|
|
this._type = 'boolean'
|
|
}
|
|
|
|
validate (value) {
|
|
if (value === undefined && this._required) return `required`
|
|
if (value === undefined) return null
|
|
/* eslint-disable-next-line */
|
|
if (typeof value !== this._type) return `${util.inspect(value, false, null)} type not ${this._type}`
|
|
return null
|
|
}
|
|
}
|
|
|
|
module.exports = TypeBoolean
|