function validated = validateTolerance(inputData, modelInterfaceStrategy)
%% validateTolerance Validate that newVal is a valid tolerance

% Copyright 2022-2023 The MathWorks, Inc.

arguments
    inputData {struct};
    modelInterfaceStrategy(1,1) DataTypeWorkflow.ModelInterfaceStrategy.ModelInterfaceStrategy = ...
        DataTypeWorkflow.ModelInterfaceStrategy.SlInterfaceStrategy();
end

if isempty(inputData.newValue)
    validated.validated = true;
    return
end

mdlRoot = modelInterfaceStrategy.bdroot(inputData.blkPath);
newVal = modelInterfaceStrategy.resolveInGlobalScope(mdlRoot,inputData.newValue);

isValid = isscalar(newVal); % Scalar;
isValid = isValid && isreal(newVal); % real
isValid = isValid && isfinite(newVal); % Finite
isValid = isValid && ~isnan(newVal); % Non-Nan
isValid = isValid && (newVal >= 0); % Non-negative

validated.validated = isValid;

end
