Skip to content

feat: add string length range assertions (HasMinLength, HasMaxLength, HasLengthBetween) #4868

@thomhurst

Description

@thomhurst

Description

The assertion library has HasLength(int length) for exact length matching but lacks range-based assertions:

  • HasMinLength(int minLength) — assert string is at least N characters
  • HasMaxLength(int maxLength) — assert string is at most N characters
  • HasLengthBetween(int min, int max) — assert string length is within a range

Why

These are common validation patterns (password lengths, field constraints, etc.). Currently users must chain verbose comparisons like .HasLength().IsGreaterThanOrEqualTo(8).And.IsLessThanOrEqualTo(16).

Suggested Approach

Add three new assertion classes using the [GenerateAssertion] pattern where possible.

Metadata

Metadata

Assignees

Labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions