comparison Lib/IMPL/DOM/Schema/Validator/RegExp.pm @ 104:196bf443b5e1

DOM::Schema RC0 inflators support, validation and some other things, Minor and major fixes almost for everything. A 'Source' property of the ValidationErrors generated from a NodeSet or a NodeList is subject to change in the future.
author wizard
date Tue, 11 May 2010 02:42:59 +0400
parents df6b4f054957
children a6e9759ff88a
comparison
equal deleted inserted replaced
103:c289ed9662ca 104:196bf443b5e1
15 BEGIN { 15 BEGIN {
16 public property message => prop_all; 16 public property message => prop_all;
17 } 17 }
18 18
19 sub CTOR { 19 sub CTOR {
20 my ($this) = @_; 20 my ($this,%args) = @_;
21 21
22 $this->message("A %Node.nodeName% doesn't match to the format %Schema.name%"); 22 $this->message($args{message} || "A %Node.nodeName% doesn't match to the format %Schema.display%");
23 } 23 }
24 24
25 sub Validate { 25 sub Validate {
26 my ($this,$node) = @_; 26 my ($this,$node,$ctx) = @_;
27 27
28 my $rx = $this->nodeValue; 28 my $rx = $this->nodeValue;
29 return new IMPL::DOM::Schema::ValidationError( 29 return new IMPL::DOM::Schema::ValidationError(
30 Node => $node, 30 Node => $node,
31 Source => $this, 31 Source => ( $ctx && $ctx->{Source} ) || $this->parentNode,
32 Schema => $this->parentNode, 32 Schema => $this->parentNode,
33 Message => $this->message 33 Message => $this->message
34 ) unless (not $node->isComplex) and $node->nodeValue =~ /$rx/; 34 ) unless (not $node->isComplex) and $node->nodeValue =~ /$rx/;
35 return ();
35 } 36 }
36 37
37 1; 38 1;