valitron
valitron copied to clipboard
Add Array Length Checks
I propose arrayLength, validateArrayLengthMin, validateArrayLengthMax, validateArrayLengthBetween. Analogs of the string length check.
The code is trivial, so I haven't included it here. I'd like to see it in the next version.
Thanks for your suggestions, I think they'd make excellent additions.
I honestly don't care much for your last line, however. Checking the length of an array is indeed not hard. But we also need tests and an update on the manual. Do we only allow arrays? Or Countable objects too? Should we support COUNT_RECURSIVE? As you can see, there is a bit more to it than just adding in count($value)
.
I'd like to see it in the next version too, and if I find the time to code it in before the next version it might be. If I don't, it won't. Unless someone is kind enough to send a PR my way, of course. I hope I'm misjudging your tone, but the way I read it is a bit rude toward the 60+ people who have contributed in the past.
You pose very good questions. My point of view was very limited and did not think about recursive counting or counting objects.
As to my tone, my apologies. I have seen others submit code chunks in the comments, and I wanted to avoid since I do not think I can submit any code that I write at work -- but I can if I re-write them at home.
I did not mean to come across as demanding. I merely wanted to express that it would be a nice-to-have in V2.