]> Dogcows Code - chaz/p5-CGI-Ex/blob - samples/app/app1/lib/App1/CustInfo.pm
CGI::Ex 2.24
[chaz/p5-CGI-Ex] / samples / app / app1 / lib / App1 / CustInfo.pm
1 package App1::CustInfo;
2
3 =head1 NAME
4
5 App1::CustInfo - enter user info and verify it
6
7 =cut
8
9 use strict;
10 use warnings;
11 use base qw(App1);
12 use CGI::Ex::Dump qw(debug);
13
14 sub hash_swap {
15 my $self = shift;
16 return {
17 countries => $self->_countries,
18 };
19 }
20
21 sub hash_fill {
22 return if shift->ready_validate;
23 return {country => 'US'};
24 }
25
26 sub hash_validation {
27 my $self = shift;
28 return {
29 'group no_alert' => 1,
30 'group no_confirm' => 1,
31 'group onevent' => [qw(change blur submit)],
32 first_name => {
33 required => 1,
34 max_len => 50,
35 custom => sub { my ($key, $val) = @_; $val ne 'Matt' },
36 custom_error => 'Too many people named Matt - please use a different first name',
37 },
38 last_name => {
39 required => 1,
40 max_len => 50,
41 min_len => 2,
42 },
43 password => {
44 required => 1,
45 max_len => 15,
46 match => 'm/[a-z]/i',
47 match_error => 'Password must contain a letter',
48 match2 => 'm/[0-9]/',
49 match2_error => 'Password must contain a number',
50 },
51 password2 => {
52 equals => 'password',
53 },
54 country => {
55 required => 1,
56 custom => sub { my ($key, $val) = @_; $self->_countries->{$val} },
57 custom_error => "Please pick from the list of valid countries",
58 }
59 };
60 }
61
62 sub _countries {
63 # this is better off in a database
64 return {
65 US => "United States",
66 CA => "Canada",
67 MX => "Mexico",
68 };
69 }
70
71 1;
This page took 0.031581 seconds and 4 git commands to generate.