function validate( opts, options, mode ) {
	if ( !isObject( options ) ) {
		return new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );
	}
	if ( mode === 0 ) {
		if ( hasOwnProp( options, 'idtype' ) ) {
			opts.idtype = options.idtype;
			if ( RDTYPES.indexOf( opts.idtype ) < 0 ) {
				return new TypeError( format( 'invalid option. `%s` option must be one of the following: "%s". Option: `%s`.', 'idtype', RDTYPES.join( '", "' ), opts.idtype ) );
			}
		}
		if ( hasOwnProp( options, 'ndtype' ) ) {
			opts.ndtype = options.ndtype;
			if ( FDTYPES.indexOf( opts.ndtype ) < 0 ) {
				return new TypeError( format( 'invalid option. `%s` option must be one of the following: "%s". Option: `%s`.', 'ndtype', FDTYPES.join( '", "' ), opts.ndtype ) );
			}
		}
	} else if ( mode === 1 && hasOwnProp( options, 'dtype' ) ) {
		opts.dtype = options.dtype;
		if ( RDTYPES.indexOf( opts.dtype ) < 0 ) {
			return new TypeError( format( 'invalid option. `%s` option must be one of the following: "%s". Option: `%s`.', 'dtype', RDTYPES.join( '", "' ), opts.dtype ) );
		}
	} else if ( hasOwnProp( options, 'dtype' ) ) { // mode === 2
		opts.dtype = options.dtype;
		if ( FDTYPES.indexOf( opts.dtype ) < 0 ) {
			return new TypeError( format( 'invalid option. `%s` option must be one of the following: "%s". Option: `%s`.', 'dtype', FDTYPES.join( '", "' ), opts.dtype ) );
		}
	}
	return null;
}
Validates function options.

## Notes

-   Validation modes:

    -   `0`: factory validation
    -   `1`: integer PRNG validation
    -   `2`: normalized PRNG validation

@private
@param {Object} opts - destination object
@param {Options} options - function options
@param {string} [options.dtype] - output array data type
@param {string} [options.idtype] - output array data type when generating integers
@param {string} [options.rdtype] - output array data type when generating normalized numbers
@param {integer} mode - validation mode
@returns {(Error|null)} null or an error object

@example
var opts = {};
var options = {
    'dtype': 'float64'
};
var err = validate( opts, options, 0 );
if ( err ) {
    throw err;
}