MCPcopy Index your code
hub / github.com/stdlib-js/stdlib / validate

Function validate

tools/snippets/lib/validate.js:46–57  ·  view source on GitHub ↗

* Validates function options. * * @private * @param {Object} opts - destination object * @param {Options} options - function options * @returns {(Error|null)} null or an error object * * @example * var opts = {}; * var options = {}; * var err = validate( opts, options ); * if ( err ) { * throw e

( opts, options )

Source from the content-addressed store, hash-verified

44* }
45*/
46function validate( opts, options ) {
47 if ( !isPlainObject( options ) ) {
48 return new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );
49 }
50 if ( hasOwnProp( options, 'TODO' ) ) {
51 opts.TODO = options.TODO;
52 if ( !isPlainObject( opts.TODO ) ) {
53 return new TypeError( format( 'invalid option. `%s` option must be a TODO. Option: `%s`.', 'TODO', opts.TODO ) );
54 }
55 }
56 return null;
57}
58
59
60// EXPORTS //

Callers 1

test.validate.jsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…