19 lines
475 B
JavaScript
19 lines
475 B
JavaScript
|
const Base = require('./base.js')
|
||
|
const util = require('util')
|
||
|
|
||
|
class TypeObject extends Base {
|
||
|
constructor () {
|
||
|
super()
|
||
|
this._type = 'object'
|
||
|
}
|
||
|
|
||
|
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 = TypeObject
|