| HTML-TurboForm documentation | Contained in the HTML-TurboForm distribution. |
Representation class for Equation constraint.
The equation constraint is supposed to be used whenever two values are to be compared. You have to give it the perl operator (ne, eq, <,>, whatever) and the two values to be compared via the params hash. Straight forward so no need for much documentation. See HTML::TurboForm doku for mopre details.
Arguments: none
returns 1 if valid, otherwise 0.
Arguments: none
returns Errormessage of Element which is connected to constraint.
Thorsten Domsch, tdomsch@gmx.de
| HTML-TurboForm documentation | Contained in the HTML-TurboForm distribution. |
package HTML::TurboForm::Constraint::Equation; use warnings; use strict; use base qw(HTML::TurboForm::Constraint); __PACKAGE__->mk_accessors( qw/ operator comp / ); sub check{ my ($self)=@_; my $result=0; my $request=$self->request; my $op=''; my $comp_val; my $val=$request->{ $self->name }; $op= $self->operator; $comp_val = $self->comp ; if (($op eq "eq") or ($op eq "ne")) { if (($val)&&($comp_val)){ $val="'$val'"; $comp_val="'$comp_val'"; } } if ($val and $op and $comp_val ){ my $equation=$val." ".$op." ".$comp_val ; return 1 if( eval($equation) ); } return 0; } sub message{ my ($self)=@_; return $self->text; } 1; __END__