Mailing List Archive

Embperl::Form::Validate question
Hi,

How can i in embperl 2.0b8 with Validate module check, if some rule
key ('user' in my example) is giving an error or not?

### script start ###
[-
use Embperl::Form::Validate ;
$validate = Embperl::Form::Validate->new();
$validate->add_rule([-key=>'user', -msg=>'Missing', required=>1]);
if ( $fdat{do} ) { $errors = $validate->validate_messages() ; }
-]
[$if @$errors $]
[$foreach $e (@$errors)$]
<font color="red">[+ $e +]</font><br>
[$endforeach$]
[$endif$]
<form method="post">
[## can't figure out how ##]
[$ if ($errors{user} == 1) $]<font color="red">User:</font>[$ else $]User:[$ endif $] <input type="text" name="user"><br>
<input type="submit" name="do" value="Do">
</form>
### script end ###

tia,


---------------------------------------------------------------------
To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
For additional commands, e-mail: embperl-help@perl.apache.org
Re: Embperl::Form::Validate question [ In reply to ]
>
> How can i in embperl 2.0b8 with Validate module check, if some rule
> key ('user' in my example) is giving an error or not?
>

You need to use validate instead of messages:

use Embperl::Form::Validate ;
$validate = Embperl::Form::Validate->new();
$validate->add_rule([-key=>'user', -msg=>'Missing', required=>1]);

$result = $validate -> validate({user2 => 1}) ;
%errors = map { $_->{key} => 1} @$result ;


Gerald

--------------------------------------------------------------
Gerald Richter ecos electronic communication services gmbh
IT-Securitylösungen * dynamische Webapplikationen * Consulting

Post: Tulpenstrasse 5 D-55276 Dienheim b. Mainz
E-Mail: richter@ecos.de Voice: +49 6133 939-122
WWW: http://www.ecos.de/ Fax: +49 6133 939-333
--------------------------------------------------------------
|
| Besuchen Sie uns auf der CeBIT vom 12. - 19. März 2003
| Messe Hannover * Halle 17 * Stand F 36
| http://www.cebit.de/
|
+-------------------------------------------------------------


---------------------------------------------------------------------
To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
For additional commands, e-mail: embperl-help@perl.apache.org
RE: Embperl::Form::Validate question [ In reply to ]
Hi,

>
> I have been looking at this module for using it in my project
> and i must say its a very powerful module. Today, i tried to
> do a quick test to see how it fits in my project. It works
> well but it throws some warnings which i have added to the
> end of this email.
>
> FYI i am using it with Catalyst. Any ideas why its throwing
> these warnings?
>

This isn't a problem. If you want to get rid of this warings, you just
have to initilize the coresponding varlibles to 0/'' in the source

Regards

Gerald


> Thank you for your help.
> Gaurav Talwar
>
> warnings:
> Use of uninitialized value in numeric lt (<) at
> /Embperl/Form/Validate.pm line 492.
> Use of uninitialized value in concatenation (.) or string at
> /Embperl/Form/Validate.pm line 392.
> Use of uninitialized value in hash element at
> /Embperl/Form/Validate/Default.pm line 120.
>
> ** Virus checked by BB-5000 Mailfilter **
> !DSPAM:416,486b4d3d164771972119835!
>

** Virus checked by BB-5000 Mailfilter **

---------------------------------------------------------------------
To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
For additional commands, e-mail: embperl-help@perl.apache.org