annotate Lib/IMPL/DOM/Schema/Validator/RegExp.pm @ 250:129e48bb5afb

DOM refactoring ObjectToDOM methods are virtual QueryToDOM uses inflators Fixed transform for the complex values in the ObjectToDOM QueryToDOM doesn't allow to use complex values (HASHes) as values for nodes (overpost problem)
author sergey
date Wed, 07 Nov 2012 04:17:53 +0400
parents b8c724f6de36
children 5aff94ba842f
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;
236
2904da230022 DOM refactoring
sergey
parents: 194
diff changeset
2 use strict;
165
76515373dac0 Added Class::Template,
wizard
parents: 148
diff changeset
3 use parent qw(IMPL::DOM::Schema::Validator);
100
df6b4f054957 Schema in progress
wizard
parents:
diff changeset
4
df6b4f054957 Schema in progress
wizard
parents:
diff changeset
5 our %CTOR = (
194
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
6 'IMPL::DOM::Schema::Validator' => sub {
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
7 my %args = @_;
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
8 $args{nodeName} ||= 'RegExp';
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
9 %args;
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
10 }
100
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 {
194
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
16 public property message => prop_all;
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
17 public property launder => prop_all;
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
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 {
194
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
22 my ($this,%args) = @_;
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
23
238
b8c724f6de36 DOM model refactoring
sergey
parents: 236
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 {
194
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
28 my ($this,$node,$ctx) = @_;
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
29
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
30 my $rx = $this->_rx() || $this->_rx( map qr{$_}, $this->nodeValue );
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
31
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
32 return new IMPL::DOM::Schema::ValidationError(
238
b8c724f6de36 DOM model refactoring
sergey
parents: 236
diff changeset
33 node => $node,
b8c724f6de36 DOM model refactoring
sergey
parents: 236
diff changeset
34 source => $ctx && $ctx->{Source} || $this->parentNode,
b8c724f6de36 DOM model refactoring
sergey
parents: 236
diff changeset
35 schema => $this->parentNode,
b8c724f6de36 DOM model refactoring
sergey
parents: 236
diff changeset
36 message => $this->message
194
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
37 ) unless (not $node->isComplex) and $node->nodeValue =~ /($rx)/;
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
38
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
39 $node->nodeValue($1) if $this->launder;
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
40
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
41 return ();
100
df6b4f054957 Schema in progress
wizard
parents:
diff changeset
42 }
df6b4f054957 Schema in progress
wizard
parents:
diff changeset
43
180
d1676be8afcc Перекодировка в utf-8
sourcer
parents: 165
diff changeset
44 1;