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

Validate array based on a schema #113

Open
szepeviktor opened this issue Feb 10, 2022 · 7 comments
Open

Validate array based on a schema #113

szepeviktor opened this issue Feb 10, 2022 · 7 comments

Comments

@szepeviktor
Copy link
Contributor

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?

@voku
Copy link
Owner

voku commented Feb 10, 2022

Sounds interesting, what kind of schema did you think of?

@szepeviktor
Copy link
Contributor Author

szepeviktor commented Feb 10, 2022

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

@rcsofttech85
Copy link

are you talking about json validation?

@szepeviktor
Copy link
Contributor Author

szepeviktor commented Aug 10, 2023

Yes. But not exclusively.

@rcsofttech85
Copy link

php has a json_validate function in its latest version ..fixing things for minor version does not make sense i guess..

@voku
Copy link
Owner

voku commented Aug 13, 2023

@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.

$json = '[{"id":1,"firstName":"Lars","lastName":"Moelleken","city":{"name":"Düsseldorf","plz":null,"infos":["lall"]}}, {"id":1,"firstName":"Sven","lastName":"Moelleken","city":{"name":"Köln","plz":null,"infos":["foo"]}}]';

@smilesrg
Copy link

smilesrg commented Feb 9, 2024

There is a tool for this https://github.com/coduo/php-matcher

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants