View Single Post
Old 11-15-2007, 02:21 PM   #4 (permalink)
Karl
The Reckoner
Advanced Programmer Top Contributor 
 
Karl's Avatar
 
Join Date: Sep 2007
Posts: 437
Thanks: 22
Karl is on a distinguished road
Default

bluesaga, another good example of this pattern can be found in the Zend Framework (in fact, they've used this kind of pattern throughout). If you look at the Zend_Valdiate class you can see that it can be used just like the class I built, it allows you to mix and match different validations to create your own valdiation group, here's some example code from the Zend Framework Reference Manual.

PHP Code:
// Create a validator chain and add validators to it
$validatorChain = new Zend_Validate();
$validatorChain->addValidator(new Zend_Validate_StringLength(612))
               ->
addValidator(new Zend_Validate_Alnum()); 
__________________
Any fool can write code that a computer can understand. Good programmers write code that humans can understand.
Karl is offline  
Reply With Quote