| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
|
|
2
|
|
|
|
|
|
|
use Moo; |
|
3
|
1
|
|
|
1
|
|
1125
|
|
|
|
1
|
|
|
|
|
5917
|
|
|
|
1
|
|
|
|
|
4
|
|
|
4
|
|
|
|
|
|
|
with 'Dancer2::Plugin::FormValidator::Role::Extension'; |
|
5
|
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = '0.82'; |
|
7
|
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
has plugin_dbic => ( |
|
9
|
|
|
|
|
|
|
is => 'ro', |
|
10
|
|
|
|
|
|
|
lazy => 1, |
|
11
|
|
|
|
|
|
|
default => sub { |
|
12
|
|
|
|
|
|
|
return shift->plugin->app->with_plugin('Dancer2::Plugin::DBIC'); |
|
13
|
|
|
|
|
|
|
} |
|
14
|
|
|
|
|
|
|
); |
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
has schema => ( |
|
17
|
|
|
|
|
|
|
is => 'ro', |
|
18
|
|
|
|
|
|
|
lazy => 1, |
|
19
|
|
|
|
|
|
|
default => sub { |
|
20
|
|
|
|
|
|
|
my $self = shift; |
|
21
|
|
|
|
|
|
|
return $self->plugin_dbic->schema($self->config->{database}); |
|
22
|
|
|
|
|
|
|
} |
|
23
|
|
|
|
|
|
|
); |
|
24
|
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
return { |
|
26
|
|
|
|
|
|
|
unique => 'Dancer2::Plugin::FormValidator::Extension::DBIC::Unique', |
|
27
|
|
|
|
|
|
|
}; |
|
28
|
0
|
|
|
0
|
0
|
|
} |
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
1; |
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
# ABSTRACT: Dancer2 FormValidator extension for checking field present in table row using DBIC. |
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
=pod |
|
35
|
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
=encoding UTF-8 |
|
38
|
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
=head1 NAME |
|
40
|
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
Dancer2::Plugin::FormValidator::Extension::DBIC - Dancer2 FormValidator extension for checking fields existence in table rows. |
|
42
|
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
=head1 VERSION |
|
44
|
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
version 0.82 |
|
46
|
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
package Validator { |
|
50
|
|
|
|
|
|
|
use Moo; |
|
51
|
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
with 'Dancer2::Plugin::FormValidator::Role::Profile'; |
|
53
|
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
sub profile { |
|
55
|
|
|
|
|
|
|
return { |
|
56
|
|
|
|
|
|
|
username => [ qw(required unique:User,username) ], |
|
57
|
|
|
|
|
|
|
}; |
|
58
|
|
|
|
|
|
|
}; |
|
59
|
|
|
|
|
|
|
} |
|
60
|
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
=head1 DISCLAIMER |
|
63
|
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
This is beta version, not stable. |
|
65
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
67
|
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
This extension provides validators database data existence for Dancer2::Plugin::FormValidator. |
|
69
|
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
L<Dancer2::Plugin::FormValidator|https://metacpan.org/pod/Dancer2::Plugin::FormValidator>. |
|
71
|
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=head1 CONFIGURATION |
|
73
|
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
set plugins => { |
|
75
|
|
|
|
|
|
|
FormValidator => { |
|
76
|
|
|
|
|
|
|
session => { |
|
77
|
|
|
|
|
|
|
namespace => '_form_validator' |
|
78
|
|
|
|
|
|
|
}, |
|
79
|
|
|
|
|
|
|
forms => { |
|
80
|
|
|
|
|
|
|
login => 'Validator', |
|
81
|
|
|
|
|
|
|
}, |
|
82
|
|
|
|
|
|
|
extensions => { |
|
83
|
|
|
|
|
|
|
dbic => { |
|
84
|
|
|
|
|
|
|
provider => 'Dancer2::Plugin::FormValidator::Extension::DBIC', |
|
85
|
|
|
|
|
|
|
database => 'default' # DBIC database |
|
86
|
|
|
|
|
|
|
} |
|
87
|
|
|
|
|
|
|
} |
|
88
|
|
|
|
|
|
|
}, |
|
89
|
|
|
|
|
|
|
}; |
|
90
|
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
config.yml: |
|
92
|
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
... |
|
94
|
|
|
|
|
|
|
plugins: |
|
95
|
|
|
|
|
|
|
FormValidator: |
|
96
|
|
|
|
|
|
|
session: |
|
97
|
|
|
|
|
|
|
namespace: '_form_validator' |
|
98
|
|
|
|
|
|
|
extensions: |
|
99
|
|
|
|
|
|
|
dbic: |
|
100
|
|
|
|
|
|
|
provider: 'Dancer2::Plugin::FormValidator::Extension::DBIC' |
|
101
|
|
|
|
|
|
|
database: 'default' # DBIC database |
|
102
|
|
|
|
|
|
|
... |
|
103
|
|
|
|
|
|
|
... |
|
104
|
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
=head1 Validators |
|
106
|
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
=head3 unique |
|
108
|
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
unique:source,column |
|
110
|
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
The field under validation must not exist within the given database source(table). |
|
112
|
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
=head1 SOURCE CODE REPOSITORY |
|
114
|
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
L<https://github.com/AlexP007/dancer2-plugin-formvalidator-extension-dbic|https://github.com/AlexP007/dancer2-plugin-formvalidator-extension-dbic>. |
|
116
|
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
=head1 AUTHOR |
|
118
|
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
Alexander Panteleev <alexpan at cpan dot org>. |
|
120
|
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
=head1 LICENSE AND COPYRIGHT |
|
122
|
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
This software is copyright (c) 2022 by Alexander Panteleev. |
|
124
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
|
125
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
|
126
|
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
=cut |