You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
ngcp-panel/lib/NGCP/Panel/Field/Regexp.pm

38 lines
696 B

package NGCP::Panel::Field::Regexp;
use HTML::FormHandler::Moose;
extends 'HTML::FormHandler::Field::Text';
sub validate {
my ( $self ) = @_;
my $pattern = $self->value;
my $valid_regexp = eval {
qr/$pattern/;
} or return $self->add_error($self->label . " is no valid regexp");
return 1;
}
no Moose;
1;
=head1 NAME
NGCP::Panel::Field::Regexp
=head1 DESCRIPTION
This accepts a regexp that can be validated in perl. It subclasses
L<HTML::FormHandler::Field::Text>.
=head1 AUTHOR
Gerhard Jungwirth
=head1 LICENSE
This library is free software. You can redistribute it and/or modify
it under the same terms as Perl itself.
=cut
# vim: set tabstop=4 expandtab: