function mustBeGreaterThanOrEqual(A, B)
%MUSTBEGREATERTHANOREQUAL Validate that value is greater than or equal to a specified value
%   MUSTBEGREATERTHANOREQUAL(A,B) throws an error if A is not greater than or equal to B.
%   MATLAB calls ge to determine if A is greater than or equal to B.
%
%   Class support:
%   All numeric classes, logical
%   MATLAB classes that define these methods:
%       ge, isscalar, isreal, isnumeric, islogical
%
%   See also: MUSTBENUMERICORLOGICAL, MUSTBEREAL.

%   Copyright 2016-2021 The MathWorks, Inc.

if ~isscalar(B)
    throwAsCaller(createValidatorException('MATLAB:validatorUsage:nonScalarSecondInput', ...
        'mustBeGreaterThanOrEqual'));
end

if ~isnumeric(B) && ~islogical(B)
    throwAsCaller(createValidatorException('MATLAB:validatorUsage:nonNumericOrLogicalInput', ...
        'mustBeGreaterThanOrEqual'));
end

if ~isnumeric(A) && ~islogical(A)
    throwAsCaller(createValidatorException('MATLAB:validators:mustBeNumericOrLogical'));
end

if ~isreal(B)
    throwAsCaller(createValidatorException('MATLAB:validatorUsage:nonRealInput', ...
        'mustBeGreaterThanOrEqual'));
end

if ~isreal(A)
    throwAsCaller(createValidatorException('MATLAB:validators:mustBeReal'));
end

if ~all(A >= B, 'all')
    throwAsCaller(createValidatorExceptionWithValue(...
        createPrintableScalar(B),...
        'MATLAB:validators:mustBeGreaterThanOrEqualGenericText',...
        'MATLAB:validators:mustBeGreaterThanOrEqual'));
end

