Task: Implement a robust options validator in /app/
Goal
Create a module that exports a function validate(data, options) used to validate a set of options for a numeric/statistics function. The function should return a TypeError when the options argument is not a proper object, and return null when all provided options (if any) are valid. Unknown options should be ignored.
Requirements
File and export
Create /app/lib/validate.js.
The module should export a single function: validate(data, options).
Input validation
If options is not an object or is null, return a TypeError.
Validate the following properties if they exist in options:
mu: must be a numeric value (typeof mu === 'number') and finite (isFinite(mu)).
s: must be a numeric value that is strictly positive (typeof s === 'number', isFinite(s), and s > 0).
accessor: must be a function (typeof accessor === 'function').
copy: must be a boolean primitive (typeof copy === 'boolean'). Note: Boolean objects (new Boolean(true)) should be rejected.
path: must be a string primitive (typeof path === 'string').
sep: must be a string primitive (typeof sep === 'string').
dtype: must be a string primitive (typeof dtype === 'string').
deepset: must be a boolean primitive (typeof deepset === 'boolean').
Unknown properties in options should be ignored (i.e., not cause an error).
Return value
If all provided options pass validation, return null.
If any provided option fails validation, return a TypeError (any message is acceptable, tests only check instance of TypeError).
Compatibility with tests
The function must work with inputs as shown in tests: