function validateFactorAttributeArg(arg, argName)
%VALIDATEFACTORATTRIBUTEARG - Validate the properties of a factor attribute
%   VALIDATEFACTORATTRIBUTEARG(ARG, ARGNAME) validates that the factor
%   attribute values ARG for an attribute named ARGNAME are specified
%   correctly. Factor attributes are things like if the factor is categorical, 
%   or if the factor is random. ARG can be:
%       1. 'all'
%       2. Indices of factors
%       3. Logical vector
%       4. Names of factors
%   If given a set of names, validation that those names appear in the model
%   happens elsewhere. Additionally, verifying that the indices are in range,
%   or the logical vector is the correct size, happens elsewhere

%   Copyright 2022 The MathWorks, Inc.
if isnumeric(arg)
    % indices
    validateattributes(arg, {'double', 'single'}, {'nonnan', 'integer', 'nonsparse', 'finite', 'real', 'vector', 'positive'}, ...
        mfilename, argName);
elseif ~(islogical(arg) && isvector(arg)) && ~(ischar(arg) && ismatrix(arg)) && ~(iscellstr(arg) && isvector(arg)) && ~(isstring(arg) && isvector(arg))
    error(message('stats:hypothesis:anova:BadTableArg', argName))
end
end