Arguments Validators
List of predefined validators that can be used in arguments block.
Description
The table below lists each validator with its full signature. In an arguments block, validators that only take the checked value (signature mustBeXxx(value)) can be written using either form:
short form, e.g.
x {mustBeReal, mustBePositive}— the argument is implicit;function-call form, e.g.
x {mustBeReal(x), mustBePositive(x)}— the argument is passed explicitly.
Validators that take additional parameters (e.g. mustBeGreaterThan, mustBeInRange, mustBeMember, mustBeA) must always use the function-call form.
| Name | Meaning | Example |
| mustBeA(value, datatype) | value must be of datatype or subtype |
|
mustBeEqualDims(value1, value2) mustBeEqualDims(value1, value2, dims) |
|
|
mustBeEqualDimsOrEmpty(value1, value2) mustBeEqualDimsOrEmpty(value1, value2, dims) |
|
|
mustBeEqualDimsOrScalar(value1, value2) mustBeEqualDimsOrScalar(value1, value2, dims) |
|
|
| mustBeFile(value) | value must be a valid file path |
mustBeFile(x) |
| mustBeFinite(value) | value must be different of %nan and %inf |
mustBeFinite(x) |
| mustBeFolder(value) | value must be a valid folder path |
mustBeFolder(x) |
| mustBeGreaterThan(value, c) | value > c |
mustBeGreaterThan(x, 10) |
| mustBeGreaterThanOrEqual(value, c) | value >= c |
mustBeGreaterThanOrEqual(x, 10) |
| mustBeInRange(value, l, u [, bounds]) | value must be in range of [u, l], bounds can be
|
|
| mustBeInteger(value) | value must be an integer value |
mustBeInteger(x) |
| mustBeLessThan(value, c) | value < c |
mustBeLessThan(x, 10) |
| mustBeLessThanOrEqual(value, c) | value <= c |
mustBeLessThanOrEqual(x, 10) |
| mustBeMember(value, members) | value must be a member of members |
mustBeMember(x, [1 3 5 7]) |
| mustBeNegative(value) | value < 0 |
mustBeNegative(x) |
| mustBeNonNan(value) | value must be different of %nan |
mustBeNonNan(x) |
| mustBeNonempty(value) | value must be non empty | mustBeNonempty(x) |
| mustBeNonnegative(value) | value >= 0 |
mustBeNonnegative(x) |
| mustBeNonpositive(value) | value <= 0 |
mustBeNonpositive(x) |
| mustBeNonsparse(value) | value is not sparse |
mustBeNonsparse(x) |
| mustBeNonzero(value) | value <> 0 |
mustBeNonzero(x) |
| mustBeNonzeroLengthText(value) | value must be a string with nonzero length |
mustBeNonzeroLengthText(x) |
| mustBeNumeric(value) | value must be a number datatype (double, ints, ...) |
mustBeNumeric(x) |
| mustBeNumericOrBoolean(value) | value must be a number datatype (double, ints, ...) or boolean |
mustBeNumericOrBoolean(x) |
| mustBeNumericOrLogical(value) | value must be a number datatype (double, ints, ...) or boolean |
mustBeNumericOrLogical(x) |
| mustBePositive(value) | value > 0 |
mustBePositive(x) |
| mustBeReal(value) | value must be real |
mustBeReal(x) |
| mustBeSameType(value1, value2) | value1 and value2 must be of same type |
mustBeSameType(x, y) |
| mustBeScalar(value) | value must be scalar |
mustBeScalar(x) |
| mustBeScalarOrEmpty(value) | value must be scalar or empty |
mustBeScalarOrEmpty(x) |
| mustBeValidVariableName(value) | value must be a valid variable name |
mustBeValidVariableName(x) |
| mustBeVector(value) | value must be a vector |
mustBeVector(x) |
| mustBeRow(value) | value must be a row vector |
mustBeRow(x) |
| mustBeColumn(value) | value must be a column vector |
mustBeColumn(x) |
| mustBeSquare(value) | value must be a square matrix |
mustBeSquare(x) |
See also
- Arguments — keyword to check function arguments. Arguments block must be the expression in the function.
History
| Version | Description |
| 2024.0 | Introduction in Scilab. |
| Report an issue | ||
| << arguments | Structure de contrôle | break >> |