Changeset 8953 for lang/perl/Sledge-Plugin-FormValidator-Lazy
- Timestamp:
- 04/06/08 09:02:15 (5 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
lang/perl/Sledge-Plugin-FormValidator-Lazy/trunk/lib/Sledge/Plugin/FormValidator/Lazy.pm
r5173 r8953 19 19 $self->{dfv_stash} = {}; 20 20 my $config = $self->create_config->form_validator_lazy; 21 my $method_pkg = $config->{method_pkg}; 21 my $method_pkg = $config->{method_pkg}; 22 22 $method_pkg->require or die $@; 23 23 $CONSTRAINTS->{_strict} … … 113 113 } 114 114 } 115 115 116 116 return $self->{form}; 117 117 … … 126 126 my $value = $data->{ $key } ; 127 127 if( ref $value eq 'ARRAY' ) { 128 my $method = $value->[0]; 128 my $method = $value->[0]; 129 129 my @args = @{ $value }; 130 130 shift @args; 131 131 my $sub = $pkg . '::' . 'static' . '_' . $method ; 132 $constraints->{ qr/$key/ } 133 = sub { 134 my $item = shift ; 132 $constraints->{ qr/$key/ } 133 = sub { 134 my $item = shift ; 135 135 no strict; 136 my $result = $sub->( $item ,@args );136 my $result = $sub->( $item , @args ); 137 137 return $result; 138 138 } … … 165 165 } 166 166 elsif ( ref $value eq 'ARRAY' ) { 167 my $method = $value->[0]; 167 my $method = $value->[0]; 168 168 my @args = @{ $value }; 169 169 shift @args; 170 170 my $sub = $pkg . '::' . 'static' . '_' . $method ; 171 $constraints->{ $key } 172 = sub { 173 my $item = shift ; 171 $constraints->{ $key } 172 = sub { 173 my $item = shift ; 174 174 no strict; 175 my $result = $sub->( $item ,@args );175 my $result = $sub->( $item , @args ); 176 176 return $result; 177 177 } … … 191 191 Sledge::Plugin::FormValidator::Lazy - use Data::FormValidator in lazy way 192 192 193 =head1 SYNOPS YS193 =head1 SYNOPSIS 194 194 195 195 package Your::Pages; 196 196 197 197 use Sledge::Plugin::FormValidator::Lazy; 198 198 199 199 ; 200 200 201 201 conf.yaml 202 202 203 203 form_validator_lazy : 204 204 method_pkg : Your::Constraints … … 224 224 my $v = $self->form->valid; 225 225 226 my $user_id = $v->{user_id} ; 226 my $user_id = $v->{user_id} ; 227 227 } 228 228 229 229 =head1 DESCRIPTION 230 230 231 This is still under develop, so be aware .231 This is still under develop, so be aware. 232 232 233 233 Implement Data::FormValidator in lazy way like L<Catalyst::Plugin::FormValidator::Lazy>
![(please configure the [header_logo] section in trac.ini)](/share/chrome/site/your_project_logo.png)