ndi.validators.mustMatchRegex
MUSTMATCHREGEX Custom validation function to ensure input matches a regular expression.
MUSTMATCHREGEX(VALUE, PATTERN) checks if the input VALUE matches the
regular expression specified by PATTERN. If VALUE does not match PATTERN,
the function throws an error.
This function is intended for use within an arguments block.
Inputs:
VALUE - The value being validated. Must be a character row vector
or a string scalar.
PATTERN - The regular expression pattern (char row vector or string scalar)
that VALUE must match.
Outputs:
(None) - Throws an error if validation fails.
Error Conditions:
- Throws 'ndi:validators:mustMatchRegex:InvalidInputType' if VALUE
is not a character row vector or string scalar.
- Throws 'ndi:validators:mustMatchRegex:NoMatch' if VALUE does not
match the PATTERN.
Example Usage in arguments block:
arguments
inputCode (1,:) char {mustBeNonempty, ndi.validators.mustMatchRegex(inputCode, '^[A-Z]{3}\d{5}$')}
end
See also: arguments, regexp