annotate Lib/IMPL/DOM/Schema/Validator/RegExp.pm @ 156:8638dd1374bf

Added template property to IMPL::Web::QueryHandler::PageFormat (this allows to specify exact template (filename, ref to a scalar, ref to a file handle)).
author wizard
date Tue, 05 Oct 2010 17:20:51 +0400
parents e6447ad85cb4
children 76515373dac0
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
100
df6b4f054957 Schema in progress
wizard
parents:
diff changeset
1 package IMPL::DOM::Schema::Validator::RegExp;
df6b4f054957 Schema in progress
wizard
parents:
diff changeset
2
df6b4f054957 Schema in progress
wizard
parents:
diff changeset
3 use base qw(IMPL::DOM::Schema::Validator);
df6b4f054957 Schema in progress
wizard
parents:
diff changeset
4
df6b4f054957 Schema in progress
wizard
parents:
diff changeset
5 our %CTOR = (
df6b4f054957 Schema in progress
wizard
parents:
diff changeset
6 'IMPL::DOM::Schema::Validator' => sub {
df6b4f054957 Schema in progress
wizard
parents:
diff changeset
7 my %args = @_;
df6b4f054957 Schema in progress
wizard
parents:
diff changeset
8 $args{nodeName} ||= 'RegExp';
df6b4f054957 Schema in progress
wizard
parents:
diff changeset
9 %args;
df6b4f054957 Schema in progress
wizard
parents:
diff changeset
10 }
df6b4f054957 Schema in progress
wizard
parents:
diff changeset
11 );
df6b4f054957 Schema in progress
wizard
parents:
diff changeset
12
df6b4f054957 Schema in progress
wizard
parents:
diff changeset
13 use IMPL::Class::Property;
df6b4f054957 Schema in progress
wizard
parents:
diff changeset
14
df6b4f054957 Schema in progress
wizard
parents:
diff changeset
15 BEGIN {
df6b4f054957 Schema in progress
wizard
parents:
diff changeset
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
df6b4f054957 Schema in progress
wizard
parents:
diff changeset
19 }
df6b4f054957 Schema in progress
wizard
parents:
diff changeset
20
df6b4f054957 Schema in progress
wizard
parents:
diff changeset
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
df6b4f054957 Schema in progress
wizard
parents:
diff changeset
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
df6b4f054957 Schema in progress
wizard
parents:
diff changeset
25 }
df6b4f054957 Schema in progress
wizard
parents:
diff changeset
26
df6b4f054957 Schema in progress
wizard
parents:
diff changeset
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
df6b4f054957 Schema in progress
wizard
parents:
diff changeset
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
df6b4f054957 Schema in progress
wizard
parents:
diff changeset
32 return new IMPL::DOM::Schema::ValidationError(
df6b4f054957 Schema in progress
wizard
parents:
diff changeset
33 Node => $node,
105
a6e9759ff88a Fixed a validation errors parameters
wizard
parents: 104
diff changeset
34 Source => $ctx && $ctx->{Source} || $this->parentNode,
100
df6b4f054957 Schema in progress
wizard
parents:
diff changeset
35 Schema => $this->parentNode,
df6b4f054957 Schema in progress
wizard
parents:
diff changeset
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
df6b4f054957 Schema in progress
wizard
parents:
diff changeset
42 }
df6b4f054957 Schema in progress
wizard
parents:
diff changeset
43
df6b4f054957 Schema in progress
wizard
parents:
diff changeset
44 1;