Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hasSize not working as expected #66

Open
1gravity opened this issue Apr 29, 2021 · 0 comments
Open

hasSize not working as expected #66

1gravity opened this issue Apr 29, 2021 · 0 comments

Comments

@1gravity
Copy link

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant