This file is indexed.

/usr/share/perl5/HTML/Widget/Constraint.pm is in libhtml-widget-perl 1.11-3.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  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
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
package HTML::Widget::Constraint;

use warnings;
use strict;
use base 'Class::Accessor::Chained::Fast';
use HTML::Widget::Error;

__PACKAGE__->mk_accessors(qw/message names not render_errors/);

*msg = \&message;

=head1 NAME

HTML::Widget::Constraint - Constraint Base Class

=head1 SYNOPSIS

    my $c = $widget->constraint( $type, @names );
    $c->message('Validation error.');
    $c->names(@names);
    $c->not(1);

=head1 DESCRIPTION

Constraint Base Class.

=head1 METHODS

=head2 default_message

Arguments: $message

Return Value: $message

Default error message for failing constraints.

=cut

sub default_message {'Invalid Input'}

=head2 init

Arguments: $widget

Called once when process() gets called for the first time.

=cut

sub init { }

=head2 javascript

Arguments: $id

Should return JavaScript for client side validation and the like.

=cut

sub javascript { }

=head2 msg

=head2 message

Arguments: $message

Contains the validation error message.

=head2 mk_message

Arguments: $message

Returns a validation error message.

=cut

sub mk_message { return $_[0]->message || $_[0]->default_message }

=head2 names

Arguments: @names

Return Value: @names

Contains names of params to test.

=head2 not

Arguments: $bool

Return Value: $bool

Negate constraint.

=head2 prepare

Arguments: $widget

Called every time process() gets called.

=cut

sub prepare { }

=head2 process

Arguments: $widget, $params, \@uploads

Return Value: \@errors

Validates params and returns a arrayref containing L<HTML::Widget::Error>
objects representing failed constraints.

=cut

sub process {
    my ( $self, $w, $params ) = @_;

    my $results = [];

    for my $name ( @{ $self->names } ) {
        my $values = $params->{$name};
        my @values = ref $values eq 'ARRAY' ? @$values : ($values);
        for my $value (@values) {
            my $result = $self->validate($value);
            push @$results,
                HTML::Widget::Error->new(
                { name => $name, message => $self->mk_message } )
                if $self->not ? $result : !$result;
        }
    }

    return $results;
}

=head2 process_js

Arguments: $id

Returns a hashref containing JavaScripts for client side validation and
the like.

=cut

sub process_js {
    my ( $self, $id ) = @_;
    my %js;
    for my $name ( @{ $self->names } ) {
        $js{$name} = $self->javascript("$id\_$name");
    }
    return \%js;
}

=head2 render_errors

Arguments: @names

A list of element names for which an error should be displayed.

If this is not set, the default behaviour is for the error to be displayed 
for all of the Constraint's named elements.  

=head2 validate

Arguments: $value

Return Value: $bool

Validates a value and returns 1 or 0.

=cut

sub validate {1}

=head1 AUTHOR

Sebastian Riedel, C<sri@oook.de>

=head1 LICENSE

This library is free software, you can redistribute it and/or modify it under
the same terms as Perl itself.

=cut

1;