Mercurial > pub > Impl
annotate Lib/IMPL/DOM/Schema/Validator/RegExp.pm @ 162:39c8788eded5
corrected PATH_INFO handling
author | wizard |
---|---|
date | Wed, 29 Dec 2010 16:55:24 +0300 |
parents | e6447ad85cb4 |
children | 76515373dac0 |
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; | |
148
e6447ad85cb4
DOM objects now have a schema and schemaSource properties
wizard
parents:
105
diff
changeset
|
17 public property launder => prop_all; |
e6447ad85cb4
DOM objects now have a schema and schemaSource properties
wizard
parents:
105
diff
changeset
|
18 private property _rx => prop_all; |
100 | 19 } |
20 | |
21 sub CTOR { | |
104
196bf443b5e1
DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents:
100
diff
changeset
|
22 my ($this,%args) = @_; |
100 | 23 |
104
196bf443b5e1
DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents:
100
diff
changeset
|
24 $this->message($args{message} || "A %Node.nodeName% doesn't match to the format %Schema.display%"); |
100 | 25 } |
26 | |
27 sub Validate { | |
104
196bf443b5e1
DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents:
100
diff
changeset
|
28 my ($this,$node,$ctx) = @_; |
100 | 29 |
148
e6447ad85cb4
DOM objects now have a schema and schemaSource properties
wizard
parents:
105
diff
changeset
|
30 my $rx = $this->_rx() || $this->_rx( map qr{$_}, $this->nodeValue ); |
e6447ad85cb4
DOM objects now have a schema and schemaSource properties
wizard
parents:
105
diff
changeset
|
31 |
100 | 32 return new IMPL::DOM::Schema::ValidationError( |
33 Node => $node, | |
105 | 34 Source => $ctx && $ctx->{Source} || $this->parentNode, |
100 | 35 Schema => $this->parentNode, |
36 Message => $this->message | |
148
e6447ad85cb4
DOM objects now have a schema and schemaSource properties
wizard
parents:
105
diff
changeset
|
37 ) unless (not $node->isComplex) and $node->nodeValue =~ /($rx)/; |
e6447ad85cb4
DOM objects now have a schema and schemaSource properties
wizard
parents:
105
diff
changeset
|
38 |
e6447ad85cb4
DOM objects now have a schema and schemaSource properties
wizard
parents:
105
diff
changeset
|
39 $node->nodeValue($1) if $this->launder; |
e6447ad85cb4
DOM objects now have a schema and schemaSource properties
wizard
parents:
105
diff
changeset
|
40 |
104
196bf443b5e1
DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents:
100
diff
changeset
|
41 return (); |
100 | 42 } |
43 | |
44 1; |