function mustBeTolerance(tol)
%MUSTBETOLERANCE Validate the Name-Value pair "Tolerance" of "checkGradients".

%   Copyright 2023 The MathWorks, Inc.
    
    if ~isscalar(tol) || ~isnumeric(tol) || ~isreal(tol) || ~(tol >= 0)
        error(message('optim:checkGradients:ToleranceMustBeNonnegativeScalar'))
    end

end

