UNPKG

validator.js-asserts

Version:
35 lines (25 loc) 484 B
'use strict'; /** * Module dependencies. */ const { Violation } = require('validator.js'); const { isPlainObject } = require('lodash'); /** * Export `PlainObjectAssert`. */ module.exports = function plainObjectAssert() { /** * Class name. */ this.__class__ = 'PlainObject'; /** * Validation algorithm. */ this.validate = value => { if (!isPlainObject(value)) { throw new Violation(this, value); } return true; }; return this; };