Skip to content
Download

length

mach::FieldValidationBuilder::length

Adds length validation.

Applies a length validation rule to a string field.

FieldValidationBuilder& length(std::size_t minLength, std::size_t maxLength);

A reference to the current FieldValidationBuilder instance.

Parameter Description
minLength The minimum allowed length.
maxLength The maximum allowed length.

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::name)
.length(3, 50);
}
Name Description
minLength Adds minimum length validation.
maxLength Adds maximum length validation.
regex Adds regular expression validation.