function mustBeMember(A, B)
%MUSTBEMEMBER Validate value is member of specified set
%   MUSTBEMEMBER(A, B) throws an error if A is not a member of B.
%   MATLAB calls ismember(A,B) to determine if A is a member of B.
%
%   Class support:
%   All numeric classes, logical, char, cellstr
%   MATLAB classes that define an ismember method.
%
%   See also: ISMEMBER.

%   Copyright 2016-2022 The MathWorks, Inc.

try
    tf = all(ismember(A, B), 'all');
catch me %#ok<NASGU>
    tf = false;
end

if ~tf
    throwAsCaller(...
        createValidatorExceptionWithValue(createPrintableList(B), ...
        'MATLAB:validators:mustBeMemberGenericText',...
        'MATLAB:validators:mustBeMember')...
        );
end
