Am Donnerstag 26 Juni 2008 10:58:08 schrieb Derick Rethans: > On Wed, 25 Jun 2008, Thomas Koch wrote: > > thanks for your work on this component! > > > > There is only one issue, about which I'm not sure if it is adressed by > > the request filter or not. > > > > I consider it to be very important for clean code to separate the input > > validation from any action or logic. This can be best reached by having > > different methods for this two tasks. > > You can not do this, as it is up to the application code > (controller/action) to decide what is valid input or not. Therefore, all > sorts of input validation *has* to be done in the controller's action. > Both the request builder and the router do not know application logical > and can therefore not validate your input. > > regards, > Derick
I've been aware of this point. Of course it is up to the controller to validate the data. Therefor I wrote, that the controller should provide a method that returns a validator class specific for this controller. My point is, that data validation and working with data are two separate things and that you should make it as easy as possible to keep them separate. Maybe some test code could make things more clear: <?php interface Controller { public function getValidator( $someParameters ); public function run( controllerSpecificData $data ); public function onInvalidData( ezcMvcRequest $request, Validator $failedValidator ); } interface Validator { /** * @return data structure with valid data or false */ public function validate( $request ); } ?> If you feed the controller with unverified input data, then you imply that every controller must look something like: <? public function run( ezcMvcRequest $request ) { $verifiedData = $this->validate( $request ); if( $verifiedData ) { $this->runVerified( $verifiedData ); } else { $this->onInvalidData( $request, $verifiedData ); } } ?> Best regards, -- Thomas Koch, Software Developer http://www.koch.ro Young Media Concepts GmbH Sonnenstr. 4 CH-8280 Kreuzlingen Switzerland Tel +41 (0)71 / 508 24 86 Fax +41 (0)71 / 560 53 89 Mobile +49 (0)170 / 753 89 16 Web www.ymc.ch -- Components mailing list Components@lists.ez.no http://lists.ez.no/mailman/listinfo/components