Mercurial > pub > Impl
annotate Lib/IMPL/DOM/Schema/Validator/RegExp.pm @ 114:7084af955c57
minor changes, more strict code, no bugs fixed, no features added
author | wizard |
---|---|
date | Tue, 25 May 2010 01:26:42 +0400 |
parents | a6e9759ff88a |
children | e6447ad85cb4 |
rev | line source |
---|---|
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 { | |
104
196bf443b5e1
DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents:
100
diff
changeset
|
20 my ($this,%args) = @_; |
100 | 21 |
104
196bf443b5e1
DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents:
100
diff
changeset
|
22 $this->message($args{message} || "A %Node.nodeName% doesn't match to the format %Schema.display%"); |
100 | 23 } |
24 | |
25 sub Validate { | |
104
196bf443b5e1
DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents:
100
diff
changeset
|
26 my ($this,$node,$ctx) = @_; |
100 | 27 |
28 my $rx = $this->nodeValue; | |
29 return new IMPL::DOM::Schema::ValidationError( | |
30 Node => $node, | |
105 | 31 Source => $ctx && $ctx->{Source} || $this->parentNode, |
100 | 32 Schema => $this->parentNode, |
33 Message => $this->message | |
34 ) unless (not $node->isComplex) and $node->nodeValue =~ /$rx/; | |
104
196bf443b5e1
DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents:
100
diff
changeset
|
35 return (); |
100 | 36 } |
37 | |
38 1; |