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

P.string.length #256

Closed
JUSTIVE opened this issue Jun 3, 2024 · 0 comments · Fixed by #257
Closed

P.string.length #256

JUSTIVE opened this issue Jun 3, 2024 · 0 comments · Fixed by #257
Labels
enhancement New feature or request

Comments

@JUSTIVE
Copy link
Contributor

JUSTIVE commented Jun 3, 2024

Is your feature request related to a problem? Please describe.
A subpattern that can be composed with P.intersect, or P.union. .when(x=>x.length) could handle this, but it doesn't guarantee string type.
the other alternative, P.intersection(P.string.minLength(len), P.string.maxLength(len)) could be equivalent, and also can be done with APIs we already have, but it's very cumbersome and the boundaries of those min and maxes(includes or not) are confusing.

Describe the solution you'd like
Add P.string.length(len: number), which matches the given value's type is string and its length is same as given len

Describe alternatives you've considered

Additional context
Add any other context or screenshots about the feature request here.

@JUSTIVE JUSTIVE added the enhancement New feature or request label Jun 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant