Re: [PHP] Re: seeking data validation class

2002-09-30 Thread Manuel Lemos

Hello,

On 09/28/2002 12:56 AM, Peter J. Schoenster wrote:
Assumming that you tried the forms generation and validation class, what
did you realize that was missing to match your needs?

http://www.phpclasses.org/formsgeneration
 
 
 Well that's the first thing I found and I downloaded it. It does much 
 more than what I want, for instance here:
 
 
 $subscription-AddInput(array(
  TYPE=text,
  NAME=email,
  MAXLENGTH=100,
  Capitalization=lowercase,
  ValidateAsEmail=1,
  ValidationErrorMessage=It was not specified a valid e-mail
  address
 ));
 
 
 Those attributes already exist in the form. I create the forms on the 
 fly only once afterwhich they are in the hands of the designers to 
 manipulate. I pass back to the form a data structure that will have 
 something like:
 
 missing_email
 invalid_email
 
 and the designer can check for this, lke this in smarty:
 
 {if $error.missing_email}Yo give me email{/if}
 {if $error.invalid_email}Please verify your email{/if}
 
 and I have a script that will generated those if statements so one 
 doesn't need to do a lot of typing. 
 
 I don't like generating the form programmatically all the time ... I 
 leave that to the *view*. 

I understand that you want a more productive development process, but I 
don't agree with the reasoning. Form layout is presentation logic but 
validation is business logic. The designer should not be required to 
understand the business logic. As a matter of fact the designer should 
not even be required to know HTML, I mean in the perfect world.



 I just want to pass the input data I received, the definition of the 
 form I'm using with this data and have the function return the 3 arrays 
 : good, invalid, missing. I've been very happy with this in Perl. 
 
 The formgen is very powerful, too powerful and too intrusive into the 
 other things I'm doing. I only need a small part of it. What I want has 
 nothing really to do with html forms, just data validation.

Yes, but you probably want client side validation to avoid the user 
going through the pain of an extra server round trip to tell him that a 
field is invalid, some times the validation logic is contextual, like 
you when the user needs to set at least one of several radio buttons, etc..

There is no way to achieve this with mixing the presentation logic with 
the business logic.

Currently, the way my class is, it is not very practical because you 
would need to mix the presentation and business logic by hand. I have my 
methods that completely isolate both logic using this class but that 
requires an external a meta-programming language that will generate the 
code that achieves that, in a way that is much more efficient than using 
Smarty. If you are interested, that is available here:

http://www.meta-language.net/

However that language is no longer PHP as you hoped. Currently it is 
also not very usable because I have had not the time to document it.

Anyway, I am working on something else based on the forms class that I 
think will be more like what you need. Basically you just feed it the 
HTML that the designer produced and it automatically will figure where 
the fields and labels are to compose the form. You may still use Smarty 
to adjust the form presentation depending on the results of an eventual 
validation request. Stay tuned.

-- 

Regards,
Manuel Lemos


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP] Re: seeking data validation class

2002-09-27 Thread Manuel Lemos

Hello,

On 09/27/2002 09:50 PM, Peter J. Schoenster wrote:
 I looked at phpclasses but saw nothing as simple as I wanted. There's a 
 Perl module which does just what I want and perhaps I'll have to port 
 it.
 
 The class accepts an assoc array of name=value, and the key to another 
 assoc array which describes the constraints for the assoc array I'm 
 passing in. Here is an example of the assoc array (it's Perl) which 
 contains all my forms and then the class returns 3 assoc arrays 
 (valid, invalid,missing using the key names, and this makes it very 
 easy to use in your templates e.g. if missing_name, or invalid_zipcode 
 etc.).
 
   my %forms = (  
 confirm_email = {
 required =
   [ qw(emailaddress emailaddress_verified 
 searchengine_accounts) ],
 constraints  =
   {
   emailaddress_verified = email,
   emailaddress   = email,
   },
   filters   = [ trim ],
 },
 verify_contact_info = {
 required =
   [ qw(country lastname firstname phone state zipcode city 
 company street) ],
 optional =
 [ qw(fax) ],  
 constraints  =
   {
   #phone  = american_phone,
   #zipcode= '/^\s*\d{5}(?:[-]\d{4})?\s*$/',
   state  = '/\w{2,}/',
   #fax= american_phone,
   },
   filters   = [ trim ],
   field_filters = { phone = [phone] },
 },
 
 The Perl module that does this is:
 
 HTML::FormValidator
 
 So far I'm find PHP stuff that does everything under the sun. 
 
 Anyone know of something like this?

Assumming that you tried the forms generation and validation class, what 
did you realize that was missing to match your needs?

http://www.phpclasses.org/formsgeneration


-- 

Regards,
Manuel Lemos


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] Re: seeking data validation class

2002-09-27 Thread Peter J. Schoenster

On 27 Sep 2002 at 22:09, Manuel Lemos wrote:

 Assumming that you tried the forms generation and validation class, what
 did you realize that was missing to match your needs?
 
 http://www.phpclasses.org/formsgeneration

Well that's the first thing I found and I downloaded it. It does much 
more than what I want, for instance here:

  $subscription-AddInput(array(
   TYPE=text,
   NAME=email,
   MAXLENGTH=100,
   Capitalization=lowercase,
   ValidateAsEmail=1,
   ValidationErrorMessage=It was not specified a valid e-mail
   address
  ));

Those attributes already exist in the form. I create the forms on the 
fly only once afterwhich they are in the hands of the designers to 
manipulate. I pass back to the form a data structure that will have 
something like:

missing_email
invalid_email

and the designer can check for this, lke this in smarty:

{if $error.missing_email}Yo give me email{/if}
{if $error.invalid_email}Please verify your email{/if}

and I have a script that will generated those if statements so one 
doesn't need to do a lot of typing. 

I don't like generating the form programmatically all the time ... I 
leave that to the *view*. 

I just want to pass the input data I received, the definition of the 
form I'm using with this data and have the function return the 3 arrays 
: good, invalid, missing. I've been very happy with this in Perl. 

The formgen is very powerful, too powerful and too intrusive into the 
other things I'm doing. I only need a small part of it. What I want has 
nothing really to do with html forms, just data validation.

Peter











-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php