mirror of
https://github.com/kasmtech/KasmVNC.git
synced 2025-01-27 08:18:43 +01:00
38 lines
645 B
Perl
38 lines
645 B
Perl
package KasmVNC::PatternValidator;
|
|
|
|
use strict;
|
|
use warnings;
|
|
use v5.10;
|
|
use Data::Dumper;
|
|
|
|
use KasmVNC::Utils;
|
|
|
|
sub new {
|
|
my ($class, $args) = @_;
|
|
my $self = bless {
|
|
pattern => $args->{pattern},
|
|
errorMessage => $args->{errorMessage}
|
|
}, $class;
|
|
}
|
|
|
|
sub validate {
|
|
my $self = shift;
|
|
$self->{configKey} = shift;
|
|
my @values = @{ listify($self->{configKey}->value()) };
|
|
|
|
foreach my $value (@values) {
|
|
$self->validateValue($value);
|
|
}
|
|
}
|
|
|
|
sub validateValue {
|
|
my $self = shift;
|
|
my $value = shift;
|
|
|
|
unless ($value =~ $self->{pattern}) {
|
|
$self->{configKey}->addErrorMessage($self->{errorMessage});
|
|
}
|
|
}
|
|
|
|
1;
|