Skip to content
Download

maxLength

mach::FieldValidationBuilder::maxLength

Adds maximum length validation.

Applies a maximum length validation rule to a string field.

FieldValidationBuilder& maxLength(std::size_t maxLength);

A reference to the current FieldValidationBuilder instance.

Parameter Description
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)
.maxLength(50);
}
Name Description
length Adds length validation.
minLength Adds minimum length validation.