length
mach::FieldValidationBuilder::length
Adds length validation.
Description
Section titled “Description”Applies a length validation rule to a string field.
Syntax
Section titled “Syntax”FieldValidationBuilder& length(std::size_t minLength, std::size_t maxLength);Return Value
Section titled “Return Value”A reference to the current FieldValidationBuilder instance.
Parameters
Section titled “Parameters”| Parameter | Description |
|---|---|
minLength |
The minimum allowed length. |
maxLength |
The maximum allowed length. |
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::name) .length(3, 50);}See Also
Section titled “See Also”| Name | Description |
|---|---|
minLength |
Adds minimum length validation. |
maxLength |
Adds maximum length validation. |
regex |
Adds regular expression validation. |