Skip to content
Download

range

mach::FieldValidationBuilder::range

Adds range validation.

Applies a range validation rule to a numeric field.

template <typename Number>
FieldValidationBuilder& range(Number minimum, Number maximum);

A reference to the current FieldValidationBuilder instance.

Parameter Description
Number The numeric type of the range bounds.
Parameter Description
minimum The minimum allowed value.
maximum The maximum allowed value.

Applying the same validation rule multiple times is allowed.

This method is not thread-safe and should only be called during validation configuration.

void validate(mach::ValidationBuilder<User>& validation) const {
validation.field(&User::age)
.range(18, 120);
}
Name Description
min Adds minimum value validation.
max Adds maximum value validation.
multipleOf Adds multiple-of validation.