File: Test.pm

package info (click to toggle)
libvalidation-class-perl 7.900057-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster
  • size: 1,616 kB
  • sloc: perl: 21,493; makefile: 2
file content (77 lines) | stat: -rw-r--r-- 1,065 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
package MyApp::Test;

use Validation::Class;

set {
    
    classes => [__PACKAGE__]
    
};

# rules mixin

mxn basic       => {
    required    => 1,
    max_length  => 255,
    filters     => [qw/trim strip/]
}; 
 
# attr(s) w/rules
 
fld id          => {
    mixin       => 'basic',
    max_length  => 11,
    required    => 0
};
 
fld name        => {
    mixin       => 'basic',
    min_length  => 5
};
 
fld email       => {
    mixin       => 'basic',
    min_length  => 3
};
 
fld login       => {
    mixin       => 'basic',
    min_length  => 5
};
 
fld password    => {
    mixin       => 'basic',
    min_length  => 5,
    min_symbols => 1
};
 
# just an attr
 
has attitude => 1; 
 
# self-validating method
 
mth create  => {
 
    input   => [qw/name email login password/],
    output  => ['+id'],
     
    using   => sub {
         
        my ($self, @args) = @_;
         
        # make sure to set id for output validation
         
    }
 
};

# build method, run automatically after new()

bld sub {
    
    shift->attitude(0)
    
};

1;