Re: RFC: PECL validation extension
| From: | Alan Knowles | Date: | Thu, 18 Sep 2003 00:49:20 +0000 |
| Subject: | Re: RFC: PECL validation extension | ||
| References: | 1 2 3 4 5 6 | Groups: | php.pear.dev |
| Request: | Send a blank email to pear-dev+get-21675@lists.php.net to get a copy of this message | ||
I came up with something very similar in PHP...
Gtk_ValidateManager
Same principle - have xml (wddx in my case), store a map of
a) what items where expected from a form (obtained by using the HTML Parser in Flexy),
b) against a test (a method in a user defined class) which return true/false
c) Message (The Incorrect value message)..
Since editing the xml/wddx file was a royal pain in the backside.. - I ended up doing a Gtk Interface to modify both the xml/wddx file and the class it'self..
The base class for validation
http://devel.akbkhome.com/svn/index.php/akpear/Gtk_ValidateManager/ValidateManager/Base.php
A Projects Validation rules
http://devel.akbkhome.com/svn/index.php/hebehaven2/ValidateHebe.php.wddx
(and the very messy code that is generated from it..)
http://devel.akbkhome.com/svn/index.php/hebehaven2/ValidateHebe.php
A typical rule file for a html page.
http://devel.akbkhome.com/svn/index.php/hebehaven2/templates/backend/members_edit.html.rules.wddx
Theres a few ideas to borrow if you like.. - I'm not sure how much it benifets from being done in C though..
What I haven't decided on yet is the following: - Is there any sense in having an auto_validate option that silently validates, or is this prone to cause more problems than it would solve?Try and avoid too much magic... - I'm sure you have spent as much of your life pooring oversomeones code for hours just cause they used one of these hidden tricks. $errors = validate($rule_file); would seem more logical.. - follow the flow of the program...
- Should all parameters declare their method (post or get)? optionally.. I guess.. - default = none = $_request..
- Currently, parameters that are received that were not declared simply ignored. I think I should force all parameters to be declared, and receiving an undeclared parameter should cause an error.a strict flag on the page... Hope that helps a bit.. :) Regards Alan -- Can you help out? Need Consulting Services or Know of a Job? http://www.akbkhome.com