function mustBeFolder(Path)
%MUSTBEFOLDER Validate that input path points to a folder
%   MUSTBEFOLDER(PATH) throws an error if PATH doesn't point to a folder.
%   MATLAB calls isfolder to determine if PATH points to a folder.
%
%   See also ISFOLDER.

%   Copyright 2020-2021 The MathWorks, Inc.

if ~isNontrivialText(Path)
    throwAsCaller(MException("MATLAB:validators:mustBeNonzeroLengthText", ...
        message("MATLAB:validators:nonzeroLengthText")));
end

tf = isfolder(Path);

if ~all(tf, 'all')
    files = string(Path);
    throwAsCaller(createExceptionForMissingItems(files(~tf), ...
        'MATLAB:validators:mustBeFolder'));
end

% LocalWords:  isfolder validators
