fortrabbit / datafilter

A data validation (sanitation) module for PHP
MIT License
10 stars 4 forks source link

Thoughts on using a standard for specifying validation rules? #5

Open alexweissman opened 9 years ago

alexweissman commented 9 years ago

I found this through your blog - awesome project!

I've been working on a similar project, and I'm considering using the JSON Schema standard for specifying form validation rules.

Any thoughts on making your module compatible with this standard?

ukautz commented 9 years ago

Hmm, very interesting indeed. Will look into that. Currently I'm primarily using JSON/YAML based validations based on the Laravel schema. Thanks for the link in any case. Some kind of standardization in the context of validation would be great, imho.

alexweissman commented 9 years ago

Hmm, actually the Laravel schema looks pretty nice! After more investigation, I'm starting to realize that the core JSON Schema is too restrictive for a lot of things we need to do, like sanitization and generating error messages. For what it's worth, I started to develop my own "[standard]"(https://github.com/alexweissman/wdvss), but honestly we'd all be better off if we could agree on something as a community.

JSON Schema can be extended in principle, but I haven't been able to get too much help on their forums with regard to exactly how that would be done. On the other hand, they seem to already be in talks with the IETF, so they might be on track to become an official standard.

I like the Laravel syntax; maybe they would be amenable to developing an extension of the JSON Schema that deals with error messages and sanitization.