range
mach::FieldValidationBuilder::range
Adds range validation.
Description
Section titled “Description”Applies a range validation rule to a numeric field.
Syntax
Section titled “Syntax”template <typename Number>FieldValidationBuilder& range(Number minimum, Number maximum);Return Value
Section titled “Return Value”A reference to the current FieldValidationBuilder instance.
Template Parameters
Section titled “Template Parameters”| Parameter | Description |
|---|---|
Number |
The numeric type of the range bounds. |
Parameters
Section titled “Parameters”| Parameter | Description |
|---|---|
minimum |
The minimum allowed value. |
maximum |
The maximum allowed value. |
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::age) .range(18, 120);}See Also
Section titled “See Also”| Name | Description |
|---|---|
min |
Adds minimum value validation. |
max |
Adds maximum value validation. |
multipleOf |
Adds multiple-of validation. |