comparison Lib/IMPL/DOM/Schema/Validator/RegExp.pm @ 194:4d0e1962161c

Replaced tabs with spaces IMPL::Web::View - fixed document model, new features (control classes, document constructor parameters)
author cin
date Tue, 10 Apr 2012 20:08:29 +0400
parents d1676be8afcc
children 2904da230022
comparison
equal deleted inserted replaced
193:8e8401c0aea4 194:4d0e1962161c
1 package IMPL::DOM::Schema::Validator::RegExp; 1 package IMPL::DOM::Schema::Validator::RegExp;
2 2
3 use parent qw(IMPL::DOM::Schema::Validator); 3 use parent qw(IMPL::DOM::Schema::Validator);
4 4
5 our %CTOR = ( 5 our %CTOR = (
6 'IMPL::DOM::Schema::Validator' => sub { 6 'IMPL::DOM::Schema::Validator' => sub {
7 my %args = @_; 7 my %args = @_;
8 $args{nodeName} ||= 'RegExp'; 8 $args{nodeName} ||= 'RegExp';
9 %args; 9 %args;
10 } 10 }
11 ); 11 );
12 12
13 use IMPL::Class::Property; 13 use IMPL::Class::Property;
14 14
15 BEGIN { 15 BEGIN {
16 public property message => prop_all; 16 public property message => prop_all;
17 public property launder => prop_all; 17 public property launder => prop_all;
18 private property _rx => prop_all; 18 private property _rx => prop_all;
19 } 19 }
20 20
21 sub CTOR { 21 sub CTOR {
22 my ($this,%args) = @_; 22 my ($this,%args) = @_;
23 23
24 $this->message($args{message} || "A %Node.nodeName% doesn't match to the format %Schema.display%"); 24 $this->message($args{message} || "A %Node.nodeName% doesn't match to the format %Schema.display%");
25 } 25 }
26 26
27 sub Validate { 27 sub Validate {
28 my ($this,$node,$ctx) = @_; 28 my ($this,$node,$ctx) = @_;
29 29
30 my $rx = $this->_rx() || $this->_rx( map qr{$_}, $this->nodeValue ); 30 my $rx = $this->_rx() || $this->_rx( map qr{$_}, $this->nodeValue );
31 31
32 return new IMPL::DOM::Schema::ValidationError( 32 return new IMPL::DOM::Schema::ValidationError(
33 Node => $node, 33 Node => $node,
34 Source => $ctx && $ctx->{Source} || $this->parentNode, 34 Source => $ctx && $ctx->{Source} || $this->parentNode,
35 Schema => $this->parentNode, 35 Schema => $this->parentNode,
36 Message => $this->message 36 Message => $this->message
37 ) unless (not $node->isComplex) and $node->nodeValue =~ /($rx)/; 37 ) unless (not $node->isComplex) and $node->nodeValue =~ /($rx)/;
38 38
39 $node->nodeValue($1) if $this->launder; 39 $node->nodeValue($1) if $this->launder;
40 40
41 return (); 41 return ();
42 } 42 }
43 43
44 1; 44 1;