Additional validator functions for Matlab.
Validoozy provides additional mustBe*()
validator functions for Matlab.
These are the input/property-validation functions introduced in Matlab R2017a.
Validoozy provides two sets of validator functions:
extend
– New validator functions that Matlab does not definecompat
– Back-compatibility implementations of the Matlab-provided validators, for use in Matlab versions prior to R2017a, or if you want to use my "label" extension
To use Validoozy, install the source tree somewhere on your disk, and then run load_validoozy
from the Mcode
directory.
My validator functions provide an additional optional "label
" argument that allows you to specify how the error message refers to the input upon validation failure.
This is useful if you are calling the validator on something besides a named variable, such as a field of a struct, or a value in a cell array.
In these cases, the validator functions are unable to automatically detect a good label via the use of inputname
, so you can supply one manually to produce a nicer error message.
Both the "extend" and "compat" implementations in Validoozy support label arguments.
If you want to use my label extension with Matlab-defined functions in R2017a and later, stick the Mcode/compat
directory on the front of your Matlab path, and I think it will work.
I've defined all the "compat" functions to be compatible with Matlab's own implementations, for the signature forms that they define.
Validoozy provides the following functions:
New functions (in Mcode/extend
):
- makeItBeA(x, type)
- mustBeA(x, type)
- mustBeCellstr(x)
- mustBeCharvec(x)
- mustBeSameSize(a, b)
- mustBeCompatibleSizes(x1, x2, ...)
- mustBeScalar(x)
- mustBeScalarLogical(x)
- mustBeVector(x)
- size2str(sz)
Pre-R2017a compatibility functions (in Mcode/compat
):
- mustBeFinite(x)
- mustBeInteger(x)
- mustBeMember(x, valid)
- mustBeNonempty(x)
- mustBeNumeric(x)
- mustBeReal(x)
Validoozy for Matlab is licensed under the business-friendly BSD 2-clause license.
The home page for Validoozy for Matlab is the Validoozy GitHub repo.
For support, feel free to post a bug report or question on the Validoozy GitHub issue tracker.
The project author is Andrew Janke.