100
|
1 package IMPL::DOM::Schema::Validator::RegExp;
|
|
2
|
|
3 use base qw(IMPL::DOM::Schema::Validator);
|
|
4
|
|
5 our %CTOR = (
|
|
6 'IMPL::DOM::Schema::Validator' => sub {
|
|
7 my %args = @_;
|
|
8 $args{nodeName} ||= 'RegExp';
|
|
9 %args;
|
|
10 }
|
|
11 );
|
|
12
|
|
13 use IMPL::Class::Property;
|
|
14
|
|
15 BEGIN {
|
|
16 public property message => prop_all;
|
|
17 }
|
|
18
|
|
19 sub CTOR {
|
|
20 my ($this) = @_;
|
|
21
|
|
22 $this->message("A %Node.nodeName% doesn't match to the format %Schema.name%");
|
|
23 }
|
|
24
|
|
25 sub Validate {
|
|
26 my ($this,$node) = @_;
|
|
27
|
|
28 my $rx = $this->nodeValue;
|
|
29 return new IMPL::DOM::Schema::ValidationError(
|
|
30 Node => $node,
|
|
31 Source => $this,
|
|
32 Schema => $this->parentNode,
|
|
33 Message => $this->message
|
|
34 ) unless (not $node->isComplex) and $node->nodeValue =~ /$rx/;
|
|
35 }
|
|
36
|
|
37 1; |