Refactoring Validate package to provide valid data
| From: | Philippe Jausions | Date: | Mon, 02 May 2005 23:18:39 +0000 |
| Subject: | Refactoring Validate package to provide valid data | ||
| Groups: | php.pear.dev | ||
| Request: | Send a blank email to pear-dev+get-37476@lists.php.net to get a copy of this message | ||
Hi all,
How many countless times have you created a form with standard input fields such as country, state/province and alike?
Since the Validate package provides validation methods, I think it would be good to have it (or a sister package) return lists of valid data that could be used in a QuickForm or other.
For example, you could do:
<?php
$form = new QuickForm('myForm');
$prov = Validate::getRegions($_REQUEST['country']);
if ($prov) {
$form->addElement('select', 'prov', 'State/Province', $prov);
$form->addRule('prov', 'Select a state/province', 'required', null, 'client');
}
?>
Whatever would be returned by Validate (or sister package) would need to follow international standards. Agreed, there's still the problem of localization, but this is typically the type of package that could be usefull to a lot of people...
Additionally to that, the Validate package (or a sister package) could have some "cleanup" methods to return valid standardized data. For instance clean up all the spaces and dash character from a credit card or social security numbers and the likes... Basically anything that is considered valid but not necessary input the same way by the end users. This would allow for more user friendly web sites.
This is so common and reusable, that there must be a way to include that in PEAR...
What do you think?
-Philippe