function mustBeOptimOptions(options)
%MUSTBEOPTIMOPTIONS Validate the thrid input "options" of "checkGradients".

%   Copyright 2023 The MathWorks, Inc.

    if ~isempty(options) && ~isa(options, 'optim.options.SolverOptions')
        if optim.internal.common.isTextScalar(options) && any(strcmpi(options, {'Display', 'Tolerance', 'IsConstraint'}))
            % The user could be missing the value for a Name-Value pair
            error(message('optim:checkGradients:MissingNVPairValue'))
        else
            error(message('optim:checkGradients:InvalidOptions'))
        end
    end

end