Validate array based on a schema
szepeviktor opened this issue · comments
What is this feature about (expected vs actual behaviour)?
Provide a schema a check validity of/fix an array.
@voku Do you happen to know a package that does this? Do you plan to implement it?
Sounds interesting, what kind of schema did you think of?
I'm not ready with the answer!
JSON schema seems to be popular but it is complex.
As far as I can see it needs only key type, value type and is_required.
...for trees and multidimensional arrays too
are you talking about json validation?
Yes. But not exclusively.
php has a json_validate function in its latest version ..fixing things for minor version does not make sense i guess..
@rcsofttech85 json_validate
only validates the JSON, not the data in the JSON
@szepeviktor It's already possible to validate / extract multidimensional data from JSON e.g.
Arrayy/tests/PHPStan/AnalyseTest.php
Line 14 in eaea456
There is a tool for this https://github.com/coduo/php-matcher