Re: Validation functions

From: Date: Mon, 24 Jun 2002 13:31:38 +0000
Subject: Re: Validation functions
References: 1 2 3 4 5  Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-7326@lists.php.net to get a copy of this message
On Mon, 24 Jun 2002 14:21:01 +0200 alexander.merz@t-online.de (Alexander Merz) wrote: > Both versions are correct, the difference between this two types is the > way of handling in case of non-valid data. > If called staticly (2) only true or false would be returned, if you call > through an instance (1) raiseError is used. That does not match the sample code you wrote :). What do you think about to always return boolean and let the user the possibility to check the error codes (we cannot manage all local errors messages) ? That will avoid wrong utilisations by users always instantiates the objects as well as a method could be could called staticly. Tomas, is this a good compromise ;) ? > Another point you should not forget are complex valdations functions. > Ie. i've wrote a validation function for checking german bank account > numbers (but never finished). This functions requires two parameters: > The bank code number and the account number. In germany there exists at > the moment 100 different checksum routines. So the function first looks > up in a database which routine to use. Then the function calls the > routine and checks the number. hey, nice :). It s one of the last IBAN and domestic account number I ve to do. I m very interested about your code (und die kennziffern gultig bis 8.09.2002, nur die nachsten kennziffern sind online). What do you need to finished the module ? I may help you if needed. > And at the end, don't forget usability. As a user of your application, i > would intrested in what is wrong, not only that something is wrong. A > validation method which only returns true/false doesn't give the > required information Job may be done by error codes. This is a must for complex validations or validations with exceptions. pa

« previous php.pear.dev (#7326) next »