@@ -24,6 +24,7 @@ var isObject = require( '@stdlib/assert-is-plain-object' );
2424var hasOwnProp = require ( '@stdlib/assert-has-own-property' ) ;
2525var isString = require ( '@stdlib/assert-is-string' ) . isPrimitive ;
2626var dtypes = require ( '@stdlib/array-typed-dtypes' ) ;
27+ var format = require ( '@stdlib/string-format' ) ;
2728var contains = require ( './contains.js' ) ;
2829
2930
@@ -57,21 +58,21 @@ var DTYPES = dtypes();
5758*/
5859function validate ( opts , options ) {
5960 if ( ! isObject ( options ) ) {
60- return new TypeError ( 'invalid argument. Options must be an object. Value: `' + options + '`.' ) ;
61+ return new TypeError ( format ( 'invalid argument. Options argument must be an object. Value: `%s`.' , options ) ) ;
6162 }
6263 if ( hasOwnProp ( options , 'dtype' ) ) {
6364 opts . dtype = options . dtype ;
6465 if ( ! isString ( opts . dtype ) ) {
65- return new TypeError ( 'invalid option. `dtype ` option must be a string. Option: `' + opts . dtype + '`.' ) ;
66+ return new TypeError ( format ( 'invalid option. `%s ` option must be a string primitive . Option: `%s`.' , 'dtype' , opts . dtype ) ) ;
6667 }
6768 if ( ! contains ( DTYPES , opts . dtype ) ) {
68- return new Error ( 'invalid option. `dtype` option must be a recognized data type. Option: `' + opts . dtype + '`.' ) ;
69+ return new Error ( format ( 'invalid option. `dtype` option must be a recognized data type. Option: `%s`.' , opts . dtype ) ) ;
6970 }
7071 }
7172 if ( hasOwnProp ( options , 'name' ) ) {
7273 opts . name = options . name ;
7374 if ( ! isString ( opts . name ) ) {
74- return new TypeError ( 'invalid option. `name ` option must be a string. Option: `' + opts . name + '`.' ) ;
75+ return new TypeError ( format ( 'invalid option. `%s ` option must be a string primitive . Option: `%s`.' , 'name' , opts . name ) ) ;
7576 }
7677 }
7778 return null ;
0 commit comments