line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
|
2
|
|
|
|
|
|
|
use strict; |
3
|
45
|
|
|
45
|
|
389588
|
|
|
45
|
|
|
|
|
130
|
|
|
45
|
|
|
|
|
1346
|
|
4
|
|
|
|
|
|
|
use Carp; |
5
|
45
|
|
|
45
|
|
202
|
|
|
45
|
|
|
|
|
96
|
|
|
45
|
|
|
|
|
2222
|
|
6
|
|
|
|
|
|
|
use base 'Rose::HTML::Object::Messages'; |
7
|
45
|
|
|
45
|
|
218
|
|
|
45
|
|
|
|
|
90
|
|
|
45
|
|
|
|
|
17472
|
|
8
|
|
|
|
|
|
|
our $VERSION = '0.600'; |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
BEGIN |
11
|
|
|
|
|
|
|
{ |
12
|
|
|
|
|
|
|
__PACKAGE__->message_names([]); |
13
|
45
|
|
|
45
|
|
431
|
__PACKAGE__->message_id_to_name_map({}); |
14
|
45
|
|
|
|
|
391
|
__PACKAGE__->message_name_to_id_map({}); |
15
|
45
|
|
|
|
|
321
|
} |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
BEGIN |
18
|
|
|
|
|
|
|
{ |
19
|
|
|
|
|
|
|
*error_ids = \&Rose::HTML::Object::Messages::message_ids; |
20
|
45
|
|
|
45
|
|
5533
|
*error_id_exists = \&Rose::HTML::Object::Messages::message_id_exists; |
21
|
45
|
|
|
|
|
119
|
*error_name_exists = \&Rose::HTML::Object::Messages::message_name_exists; |
22
|
45
|
|
|
|
|
78
|
|
23
|
|
|
|
|
|
|
*get_error_id = \&Rose::HTML::Object::Messages::get_message_id; |
24
|
45
|
|
|
|
|
111
|
*get_error_name = \&Rose::HTML::Object::Messages::get_message_name; |
25
|
45
|
|
|
|
|
76
|
|
26
|
|
|
|
|
|
|
*add_error = \&Rose::HTML::Object::Messages::add_message; |
27
|
45
|
|
|
|
|
82
|
*add_errors = \&Rose::HTML::Object::Messages::add_messages; |
28
|
45
|
|
|
|
|
89
|
*get_error_id = \&Rose::HTML::Object::Messages::get_message_id; |
29
|
45
|
|
|
|
|
78
|
|
30
|
|
|
|
|
|
|
*add_error = \&Rose::HTML::Object::Messages::add_message; |
31
|
45
|
|
|
|
|
94
|
*add_errors = \&Rose::HTML::Object::Messages::add_messages; |
32
|
45
|
|
|
|
|
74
|
|
33
|
|
|
|
|
|
|
*error_names = \&Rose::HTML::Object::Messages::message_names; |
34
|
45
|
|
|
|
|
11468
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
{ |
37
|
|
|
|
|
|
|
my($class) = shift; |
38
|
|
|
|
|
|
|
|
39
|
193
|
|
|
193
|
0
|
429
|
my $list = $class->error_names; |
40
|
|
|
|
|
|
|
|
41
|
193
|
|
|
|
|
654
|
$class->export_tags |
42
|
|
|
|
|
|
|
( |
43
|
|
|
|
|
|
|
all => $list, |
44
|
|
|
|
|
|
|
field => [ grep { /^FIELD_/ } @$list ], |
45
|
|
|
|
|
|
|
form => [ grep { /^FORM_/ } @$list ], |
46
|
4847
|
|
|
|
|
8231
|
date => [ grep { /^DATE_/ } @$list ], |
47
|
4847
|
|
|
|
|
6941
|
time => [ grep { /^TIME_/ } @$list ], |
48
|
4847
|
|
|
|
|
16431
|
email => [ grep { /^EMAIL_/ } @$list ], |
49
|
4847
|
|
|
|
|
7085
|
phone => [ grep { /^PHONE_/ } @$list ], |
50
|
4847
|
|
|
|
|
6743
|
number => [ grep { /^NUM_/ } @$list ], |
51
|
4847
|
|
|
|
|
7023
|
set => [ grep { /^SET_/ } @$list ], |
52
|
4847
|
|
|
|
|
7415
|
string => [ grep { /^STRING_/ } @$list ], |
53
|
4847
|
|
|
|
|
6686
|
); |
54
|
193
|
|
|
|
|
1925
|
} |
|
4847
|
|
|
|
|
7504
|
|
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
# |
57
|
|
|
|
|
|
|
# Errors |
58
|
|
|
|
|
|
|
# |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
use constant CUSTOM_ERROR => -1; |
61
|
|
|
|
|
|
|
|
62
|
45
|
|
|
45
|
|
307
|
# Field errors |
|
45
|
|
|
|
|
119
|
|
|
45
|
|
|
|
|
2683
|
|
63
|
|
|
|
|
|
|
use constant FIELD_REQUIRED => 3; |
64
|
|
|
|
|
|
|
use constant FIELD_PARTIAL_VALUE => 8; |
65
|
45
|
|
|
45
|
|
264
|
use constant FIELD_INVALID => 9; |
|
45
|
|
|
|
|
100
|
|
|
45
|
|
|
|
|
2375
|
|
66
|
45
|
|
|
45
|
|
270
|
|
|
45
|
|
|
|
|
85
|
|
|
45
|
|
|
|
|
2058
|
|
67
|
45
|
|
|
45
|
|
232
|
# Form errors |
|
45
|
|
|
|
|
96
|
|
|
45
|
|
|
|
|
2110
|
|
68
|
|
|
|
|
|
|
use constant FORM_HAS_ERRORS => 100; |
69
|
|
|
|
|
|
|
|
70
|
45
|
|
|
45
|
|
244
|
# Numerical errors |
|
45
|
|
|
|
|
75
|
|
|
45
|
|
|
|
|
1953
|
|
71
|
|
|
|
|
|
|
use constant NUM_INVALID_INTEGER => 1300; |
72
|
|
|
|
|
|
|
use constant NUM_INVALID_INTEGER_POSITIVE => 1301; |
73
|
45
|
|
|
45
|
|
222
|
use constant NUM_NOT_POSITIVE_INTEGER => 1302; |
|
45
|
|
|
|
|
99
|
|
|
45
|
|
|
|
|
2011
|
|
74
|
45
|
|
|
45
|
|
260
|
use constant NUM_BELOW_MIN => 1303; |
|
45
|
|
|
|
|
83
|
|
|
45
|
|
|
|
|
2481
|
|
75
|
45
|
|
|
45
|
|
229
|
use constant NUM_ABOVE_MAX => 1304; |
|
45
|
|
|
|
|
80
|
|
|
45
|
|
|
|
|
1929
|
|
76
|
45
|
|
|
45
|
|
287
|
use constant NUM_INVALID_NUMBER => 1305; |
|
45
|
|
|
|
|
88
|
|
|
45
|
|
|
|
|
2037
|
|
77
|
45
|
|
|
45
|
|
236
|
use constant NUM_INVALID_NUMBER_POSITIVE => 1306; |
|
45
|
|
|
|
|
84
|
|
|
45
|
|
|
|
|
1872
|
|
78
|
45
|
|
|
45
|
|
233
|
use constant NUM_NOT_POSITIVE_NUMBER => 1307; |
|
45
|
|
|
|
|
84
|
|
|
45
|
|
|
|
|
1916
|
|
79
|
45
|
|
|
45
|
|
227
|
|
|
45
|
|
|
|
|
79
|
|
|
45
|
|
|
|
|
2185
|
|
80
|
45
|
|
|
45
|
|
250
|
|
|
45
|
|
|
|
|
155
|
|
|
45
|
|
|
|
|
1994
|
|
81
|
|
|
|
|
|
|
# String errors |
82
|
|
|
|
|
|
|
use constant STRING_OVERFLOW => 1400; |
83
|
|
|
|
|
|
|
|
84
|
45
|
|
|
45
|
|
227
|
# Date errors |
|
45
|
|
|
|
|
87
|
|
|
45
|
|
|
|
|
1973
|
|
85
|
|
|
|
|
|
|
use constant DATE_INVALID => 1500; |
86
|
|
|
|
|
|
|
use constant DATE_MIN_GREATER_THAN_MAX => 1501; |
87
|
45
|
|
|
45
|
|
708
|
|
|
45
|
|
|
|
|
96
|
|
|
45
|
|
|
|
|
2007
|
|
88
|
45
|
|
|
45
|
|
229
|
# Time errors |
|
45
|
|
|
|
|
85
|
|
|
45
|
|
|
|
|
1858
|
|
89
|
|
|
|
|
|
|
use constant TIME_INVALID => 1550; |
90
|
|
|
|
|
|
|
use constant TIME_INVALID_HOUR => 1551; |
91
|
45
|
|
|
45
|
|
226
|
use constant TIME_INVALID_MINUTE => 1552; |
|
45
|
|
|
|
|
285
|
|
|
45
|
|
|
|
|
1913
|
|
92
|
45
|
|
|
45
|
|
233
|
use constant TIME_INVALID_SECONDS => 1553; |
|
45
|
|
|
|
|
83
|
|
|
45
|
|
|
|
|
1922
|
|
93
|
45
|
|
|
45
|
|
235
|
use constant TIME_INVALID_AMPM => 1554; |
|
45
|
|
|
|
|
94
|
|
|
45
|
|
|
|
|
2122
|
|
94
|
45
|
|
|
45
|
|
273
|
|
|
45
|
|
|
|
|
106
|
|
|
45
|
|
|
|
|
2159
|
|
95
|
45
|
|
|
45
|
|
247
|
# Email errors |
|
45
|
|
|
|
|
94
|
|
|
45
|
|
|
|
|
1899
|
|
96
|
|
|
|
|
|
|
use constant EMAIL_INVALID => 1600; |
97
|
|
|
|
|
|
|
|
98
|
45
|
|
|
45
|
|
228
|
# Phone errors |
|
45
|
|
|
|
|
98
|
|
|
45
|
|
|
|
|
2105
|
|
99
|
|
|
|
|
|
|
use constant PHONE_INVALID => 1650; |
100
|
|
|
|
|
|
|
|
101
|
45
|
|
|
45
|
|
244
|
# Set errors |
|
45
|
|
|
|
|
89
|
|
|
45
|
|
|
|
|
2346
|
|
102
|
|
|
|
|
|
|
use constant SET_INVALID_QUOTED_STRING => 1700; |
103
|
|
|
|
|
|
|
use constant SET_PARSE_ERROR => 1701; |
104
|
45
|
|
|
45
|
|
318
|
|
|
45
|
|
|
|
|
80
|
|
|
45
|
|
|
|
|
1938
|
|
105
|
45
|
|
|
45
|
|
232
|
BEGIN { __PACKAGE__->add_errors } |
|
45
|
|
|
|
|
79
|
|
|
45
|
|
|
|
|
1899
|
|
106
|
|
|
|
|
|
|
|
107
|
45
|
|
|
45
|
|
220
|
1; |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
=head1 NAME |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
Rose::HTML::Object::Errors - Error ids and named constants for use with HTML objects. |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
=head1 SYNOPSIS |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
package My::HTML::Object::Errors; |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
use strict; |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
# Import the standard set of error ids |
121
|
|
|
|
|
|
|
use Rose::HTML::Object::Errors qw(:all); |
122
|
|
|
|
|
|
|
use base qw(Rose::HTML::Object::Errors); |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
## |
125
|
|
|
|
|
|
|
## Define your new error ids below |
126
|
|
|
|
|
|
|
## |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
# Error ids from 0 to 29,999 are reserved for built-in errors. |
129
|
|
|
|
|
|
|
# Negative error ids are reserved for internal use. Please use error |
130
|
|
|
|
|
|
|
# ids 30,000 or higher for your errors. Suggested error id ranges |
131
|
|
|
|
|
|
|
# and naming conventions for various error types are shown below. |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
# Field errors |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
use constant FIELD_ERROR_PASSWORD_TOO_SHORT => 101_000; |
136
|
|
|
|
|
|
|
use constant FIELD_ERROR_USERNAME_INVALID => 101_001; |
137
|
|
|
|
|
|
|
... |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
# Generic errors |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
use constant LOGIN_NO_SUCH_USER => 200_000; |
142
|
|
|
|
|
|
|
use constant LOGIN_USER_EXISTS_ERROR => 200_001; |
143
|
|
|
|
|
|
|
... |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
# This line must be below all the "use constant ..." declarations |
146
|
|
|
|
|
|
|
BEGIN { __PACKAGE__->add_errors } |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
1; |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
=head1 DESCRIPTION |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
L<Rose::HTML::Object::Errors> stores error ids and names. The error ids are defined as Perl L<constants|constant> with integer values. The constants themselves as well as the mapping between the symbolic constant names and their values are stored as class data. |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
If you merely want to import one of the standard error id constants, you may use this module as-is (see the L<EXPORTS|/EXPORTS> section for details). If you want to define your own errors, you must subclass this module exactly as shown in the synopsis. The order of the statements is important! |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
When adding your own errors, you are free to choose any integer error id values, subject to the following constraints. |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
=over 4 |
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
=item * Error ids from 0 to 29,999 are reserved for built-in errors. |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
=item * Negative error ids are reserved for internal use. |
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
=back |
165
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
Please use ids 30,000 or higher for your errors. Constant names may contain only the characters C<[A-Z0-9_]> and must be unique among all error constant names. |
167
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
=head1 EXPORTS |
169
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
L<Rose::HTML::Object::Errors> does not export any symbols by default. |
171
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
The 'all' tag: |
173
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
use Rose::HTML::Object::Errors qw(:all); |
175
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
will cause all error name constant to be imported. |
177
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
The following tags will cause all errors whose names match the regular expression to the right of the tag name to be imported. |
179
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
TAG NAME REGEX |
181
|
|
|
|
|
|
|
----- ---------- |
182
|
|
|
|
|
|
|
field ^FIELD_ |
183
|
|
|
|
|
|
|
form ^FORM_ |
184
|
|
|
|
|
|
|
date ^DATE_ |
185
|
|
|
|
|
|
|
time ^TIME_ |
186
|
|
|
|
|
|
|
email ^EMAIL_ |
187
|
|
|
|
|
|
|
phone ^PHONE_ |
188
|
|
|
|
|
|
|
number ^NUM_ |
189
|
|
|
|
|
|
|
set ^SET_ |
190
|
|
|
|
|
|
|
string ^STRING_ |
191
|
|
|
|
|
|
|
|
192
|
|
|
|
|
|
|
For example, this will import all the error constants whose names begin with "FIELD_" |
193
|
|
|
|
|
|
|
|
194
|
|
|
|
|
|
|
use Rose::HTML::Object::Errors qw(:field); |
195
|
|
|
|
|
|
|
|
196
|
|
|
|
|
|
|
Finally, you can import individual error constant names as well: |
197
|
|
|
|
|
|
|
|
198
|
|
|
|
|
|
|
use Rose::HTML::Object::Errors qw(FIELD_REQUIRED NUM_INVALID_INTEGER); |
199
|
|
|
|
|
|
|
|
200
|
|
|
|
|
|
|
A complete listing of the default set of error constant names appears in the next section. |
201
|
|
|
|
|
|
|
|
202
|
|
|
|
|
|
|
=head1 BUILT-IN ERRORS |
203
|
|
|
|
|
|
|
|
204
|
|
|
|
|
|
|
The list of built-in errors appears below. You should not rely on the actual numeric values of these constants. Import and refer to them only by their symbolic names. |
205
|
|
|
|
|
|
|
|
206
|
|
|
|
|
|
|
FIELD_REQUIRED |
207
|
|
|
|
|
|
|
FIELD_PARTIAL_VALUE |
208
|
|
|
|
|
|
|
FIELD_INVALID |
209
|
|
|
|
|
|
|
|
210
|
|
|
|
|
|
|
FORM_HAS_ERRORS |
211
|
|
|
|
|
|
|
|
212
|
|
|
|
|
|
|
NUM_INVALID_INTEGER |
213
|
|
|
|
|
|
|
NUM_INVALID_INTEGER_POSITIVE |
214
|
|
|
|
|
|
|
NUM_NOT_POSITIVE_INTEGER |
215
|
|
|
|
|
|
|
NUM_BELOW_MIN |
216
|
|
|
|
|
|
|
NUM_ABOVE_MAX |
217
|
|
|
|
|
|
|
NUM_INVALID_NUMBER |
218
|
|
|
|
|
|
|
NUM_INVALID_NUMBER_POSITIVE |
219
|
|
|
|
|
|
|
NUM_NOT_POSITIVE_NUMBER |
220
|
|
|
|
|
|
|
|
221
|
|
|
|
|
|
|
STRING_OVERFLOW |
222
|
|
|
|
|
|
|
|
223
|
|
|
|
|
|
|
DATE_INVALID |
224
|
|
|
|
|
|
|
DATE_MIN_GREATER_THAN_MAX |
225
|
|
|
|
|
|
|
|
226
|
|
|
|
|
|
|
TIME_INVALID |
227
|
|
|
|
|
|
|
TIME_INVALID_HOUR |
228
|
|
|
|
|
|
|
TIME_INVALID_MINUTE |
229
|
|
|
|
|
|
|
TIME_INVALID_SECONDS |
230
|
|
|
|
|
|
|
TIME_INVALID_AMPM |
231
|
|
|
|
|
|
|
|
232
|
|
|
|
|
|
|
EMAIL_INVALID |
233
|
|
|
|
|
|
|
|
234
|
|
|
|
|
|
|
PHONE_INVALID |
235
|
|
|
|
|
|
|
|
236
|
|
|
|
|
|
|
SET_INVALID_QUOTED_STRING |
237
|
|
|
|
|
|
|
SET_PARSE_ERROR |
238
|
|
|
|
|
|
|
|
239
|
|
|
|
|
|
|
=head1 CLASS METHODS |
240
|
|
|
|
|
|
|
|
241
|
|
|
|
|
|
|
=over 4 |
242
|
|
|
|
|
|
|
|
243
|
|
|
|
|
|
|
=item B<add_error NAME, ID> |
244
|
|
|
|
|
|
|
|
245
|
|
|
|
|
|
|
Add a new error constant with NAME and an integer ID value. Error ids from 0 to 29,999 are reserved for built-in errors. Negative error ids are reserved for internal use. Please use error ids 30,000 or higher for your errors. Constant names may contain only the characters C<[A-Z0-9_]> and must be unique among all error names. |
246
|
|
|
|
|
|
|
|
247
|
|
|
|
|
|
|
=item B<add_errors [NAME1, NAME2, ...]> |
248
|
|
|
|
|
|
|
|
249
|
|
|
|
|
|
|
If called with no arguments, this method L<adds|/add_error> all error L<constants|constant> defined in the calling class. Example: |
250
|
|
|
|
|
|
|
|
251
|
|
|
|
|
|
|
__PACKAGE__->add_errors; |
252
|
|
|
|
|
|
|
|
253
|
|
|
|
|
|
|
If called with a list of constant names, add each named constant to the list of errors. These L<constants|constant> must already exist in the calling class. Example: |
254
|
|
|
|
|
|
|
|
255
|
|
|
|
|
|
|
use constant MY_ERROR1 => 123456; |
256
|
|
|
|
|
|
|
use constant MY_ERROR2 => 123457; |
257
|
|
|
|
|
|
|
... |
258
|
|
|
|
|
|
|
__PACKAGE__->add_errors('MY_ERROR1', 'MY_ERROR2'); |
259
|
|
|
|
|
|
|
|
260
|
|
|
|
|
|
|
=item B<get_error_id NAME> |
261
|
|
|
|
|
|
|
|
262
|
|
|
|
|
|
|
Returns the integer error id corresponding to the symbolic constant NAME, or undef if no such name exists. |
263
|
|
|
|
|
|
|
|
264
|
|
|
|
|
|
|
=item B<get_error_name ID> |
265
|
|
|
|
|
|
|
|
266
|
|
|
|
|
|
|
Returns the symbolic error constant name corresponding to the integer error ID, or undef if no such error ID exists. |
267
|
|
|
|
|
|
|
|
268
|
|
|
|
|
|
|
=item B<error_id_exists ID> |
269
|
|
|
|
|
|
|
|
270
|
|
|
|
|
|
|
Return true of the integer error ID exists, false otherwise. |
271
|
|
|
|
|
|
|
|
272
|
|
|
|
|
|
|
=item B<error_name_exists NAME> |
273
|
|
|
|
|
|
|
|
274
|
|
|
|
|
|
|
Return true of the symbolic error constant NAME exists, false otherwise. |
275
|
|
|
|
|
|
|
|
276
|
|
|
|
|
|
|
=item B<error_ids> |
277
|
|
|
|
|
|
|
|
278
|
|
|
|
|
|
|
Returns a list (in list context) or reference to an array (in scalar context) of integer error ids. |
279
|
|
|
|
|
|
|
|
280
|
|
|
|
|
|
|
=item B<error_names> |
281
|
|
|
|
|
|
|
|
282
|
|
|
|
|
|
|
Returns a list (in list context) or reference to an array (in scalar context) of error names. |
283
|
|
|
|
|
|
|
|
284
|
|
|
|
|
|
|
=back |
285
|
|
|
|
|
|
|
|
286
|
|
|
|
|
|
|
=head1 AUTHOR |
287
|
|
|
|
|
|
|
|
288
|
|
|
|
|
|
|
John C. Siracusa (siracusa@gmail.com) |
289
|
|
|
|
|
|
|
|
290
|
|
|
|
|
|
|
=head1 LICENSE |
291
|
|
|
|
|
|
|
|
292
|
|
|
|
|
|
|
Copyright (c) 2010 by John C. Siracusa. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. |