function create( src ) {
	var validVals;
	var comments;
	var jsdoc;
	var param;
	var opts;
	var tags;
	var type;
	var ast;
	var out;
	var tag;
	var h;
	var i;

	if ( isBuffer( src ) ) {
		src = src.toString();
	}
	else if ( !isString( src ) ) {
		throw new TypeError( format( 'invalid argument. Must provide either a string or Buffer. Value: `%s`.', src ) );
	}
	comments = [];
	parse( src, {
		'ecmaVersion': 'latest',
		'onComment': comments
	});
	jsdoc = extractOptionsJSDoc( comments );
	if ( !isString( jsdoc ) ) {
		throw new Error( 'invalid argument. Source code does not contain JSDoc comment with function options.' );
	}
	ast = doctrine.parse( jsdoc, {
		'sloppy': true,
		'unwrap': true
	});
	tags = ast.tags;
	out = START;
	validVals = [];
	for ( i = 0; i < tags.length; i++ ) {
		tag = tags[ i ];
		if (
			isObject( tag.type ) &&
			tag.type.type === 'OptionalType' &&
			startsWith( tag.name, 'options.' )
		) {
			param = replace( tag.name, 'options.', '' );
			out += '\n';
			if ( tag.type.expression.type === 'NameExpression' ) {
				type = tag.type.expression.name;
				if ( hasOwn( VALID_VALS, type ) ) {
					validVals.push( '\''+param+'\': '+VALID_VALS[ type ] );
				}
				out += createTest( param, type );
			}
			else if ( tag.type.expression.type === 'UnionType' ) {
				out += createUnionTest( param, tag.type.expression.elements );
			}
		}
	}
	out += '\n';
	out += replace( VALID, '{{valid}}', validVals.join( ',\n\t\t' ) );
	out += '\n';
	out += UNRECOGNIZED;

	// Generate a license header:
	opts = {
		'year': CURRENT_YEAR,
		'copyright': 'The Stdlib Authors'
	};
	h = licenseHeader( 'Apache-2.0', 'js', opts );

	// Insert the header:
	out = insertHeader( out, h );
	return out;
}
Returns contents of a `test.validate.js` file.

@param {(string|Buffer)} src - source code
@returns {string} validate.js tests

@example
var create = require( '@stdlib/_tools/scaffold/test-validate-js' );

var code = [
    '/**',
    '* Validates function options.',
    '*',
    '* @private',
    '* @param {Object} opts - destination object',
    '* @param {Options} options - function options',
    '* @param {string} [options.sep] - separator',
    '* @returns {(Error|null)} null or an error object',
    '*\/'
];
code = code.join( '\n' );

var tests = create( code );