regex
mach::FieldValidationBuilder::regex
Adds regular expression validation.
Description
Section titled “Description”Applies a regular expression validation rule to a string field.
Syntax
Section titled “Syntax”FieldValidationBuilder& regex(std::string_view pattern);Return Value
Section titled “Return Value”A reference to the current FieldValidationBuilder instance.
Parameters
Section titled “Parameters”| Parameter | Description |
|---|---|
pattern |
The regular expression pattern to match. |
Remarks
Section titled “Remarks”Applying the same validation rule multiple times is allowed.
Thread Safety
Section titled “Thread Safety”This method is not thread-safe and should only be called during validation configuration.
Example
Section titled “Example”void validate(mach::ValidationBuilder<User>& validation) const { validation.field(&User::username) .regex("^[a-zA-Z0-9_]+$");}See Also
Section titled “See Also”| Name | Description |
|---|---|
email |
Adds email validation. |
url |
Adds URL validation. |
length |
Adds length validation. |