How to validate array length #181
Unanswered
BigDog1400
asked this question in
Q&A
Replies: 1 comment
-
Hey! match(array)
.with(
{ status: 'success', data: [] }
() => "matches empty arrays"
)
.with(
{ status: 'success', data: [P.any] }
() => "matches arrays with exactly 1 element"
)
.with(
{ status: 'success', data: [P.any, P.any] }
() => "matches arrays with exactly 2 elements"
)
.with(
{ status: 'success', data: [P.any, ...P.array()] }
() => "matches arrays with at least 1 element"
) |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hi. I am trying to understand how to make a case for 1) array.length is greater than > 0 2) array.length is 0.


This works fine. But i don't want to nest another match. I will like to something like this, but i think that it cause another permutations to exist and it throw some errors
I also try with the P.array but i don't fully understand the release notes 😅 .
so... does someone knows the best way to validate array length?
Beta Was this translation helpful? Give feedback.
All reactions