Re[4]: [PEAR] [QF] - add rule - callback rule usingbuilt-in/registered rule inside
| From: | Sebastian Baran | Date: | Tue, 27 Jan 2004 12:36:52 +0000 |
| Subject: | Re[4]: [PEAR] [QF] - add rule - callback rule usingbuilt-in/registered rule inside | ||
| References: | 1 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-10379@lists.php.net to get a copy of this message | ||
Tuesday, January 27, 2004, 12:50:25 PM, you wrote:
>> -----Original Message-----
>> From: Bertrand Mansion [mailto:bmansion@mamasam.com]
>>
>> <Sebastian.Baran@dialcom.com.pl> wrote :
>>
>> >
>> >
>> > Tuesday, January 27, 2004, 11:40:20 AM, you wrote:
>> >
>> >>> -----Original Message-----
>> >>> From: Sebastian Baran [mailto:Sebastian.Baran@dialcom.com.pl]
>> >>>
>> >>> I want to create custom callback rule. But part of it's
>> functionality
>> >>> is going to be the same as one of built-in rules. My
>> question is - is
>> >>> it possible to call built-in rule from my callback function? Or
>> >>> do I have to rewrite built-in rule functionality by hand in my
>> >>> function?
>> >
>> > MC> Depending on exactly what your rule is going to do,
>> > MC> could you not add the rules in the right order, so that
>> the built-in one
>> > is
>> > MC> called before your custom callback one?
>> >
>> > MC> - Mike
>> >
>> >
>> > Well, I didn't think about it this way. It's good idea - I'll try to
>> > put two rules instead of one complex rule. This will be
>> sufficient for
>> > most cases.
>> >
>> > But if I would like to have just one rule to overwrite
>> error messages
>> > generated by two rules and display just one error message? For
>> > example:
>> > - one rule - built-in 'email' to initially check if email is ok
>> > - second rule - callback to check something more complex
>> (for example
>> > if email is in DB or something).
>> >
>> > Is it good way to do it? Can I put both rules into one callback rule
>> > calling buil-in rule first?
>>
>> I don't see any reason why you would want to do that ?
MC> If the email address "ok" check (via regex) is done on the client side
MC> before submitting the data to the server this should be fine. Because the
MC> second check (to see if its in the dbase) would not happen unless phase 1
MC> was passed.
MC> However if all validation is server side only - ie regex on the server,
MC> followed by a DB lookup, then two error messages would be returned - in
MC> effect telling the user the same thing twice!
MC> - The email address is not valid
MC> - The email address is not in the database
MC> Doesnt look too great as one infers the other. Computers are supposed to
MC> be clever ;-)
Well, it seems you're right about it :-) Thanks for helping me to see it
from other side :-)
--
Best regards,
Sebastian