Skip to content

hasSize not working as expectedΒ #66

Open
@1gravity

Description

Is your feature request related to a problem? Please describe.

I used hasSize(100) expecting the validation to be at most 100 characters long which isn't what's happening though.
The function is defined as:
hasSize(min: Int = Int.MIN_VALUE, max: Int = Int.MAX_VALUE)
which translates to hasSize(100, Int.MAX_VALUE).

Describe the solution you'd like

I think there should be a one parameter function hasSize(size: Int) to prevent these misunderstandings and the two parameter function should not have default values for min/max.

  • hasSize(size: Int) -> matches exact size / length
  • hasSize(min: Int, max: Int) -> matches size in [min, max]

Describe alternatives you've considered

To be even clearer with the intention I suggest:

  • hasSize(size: Int) -> matches exact size / length
  • hasSize(range: IntRange) -> matches size defined by IntRange

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions