comparison Lib/IMPL/DOM/Schema/Property.pm @ 103:c289ed9662ca

Schema beta 2 More strict validation, support for inflating a simple nodes and properties
author wizard
date Fri, 07 May 2010 18:17:40 +0400
parents d8dc6cad3f55
children 196bf443b5e1
comparison
equal deleted inserted replaced
102:cf3b6ef2be22 103:c289ed9662ca
32 } 32 }
33 33
34 sub Validate { 34 sub Validate {
35 my ($this,$node) = @_; 35 my ($this,$node) = @_;
36 36
37 if ($this->minOccur) { 37 my $prop = $this->name;
38 my $prop = $this->name; 38
39 my $nodeProp = new IMPL::DOM::Node(nodeName => '::property', nodeValue => eval { $node->$prop() } || $node->nodeProperty($prop)); 39 # buld a pseudo node for the property value
40 my $nodeProp = new IMPL::DOM::Node(nodeName => '::property', nodeValue => eval { $node->$prop() } || $node->nodeProperty($prop));
40 41
41 if (! $nodeProp->nodeValue) { 42 if ($nodeProp->nodeValue) {
42 return new IMPL::DOM::Schema::ValidationError( 43 # we have a value so validate it
43 Message => $this->RequiredMessage, 44 return $this->SUPER::Validate($nodeProp);
44 Node => $node, 45 } elsif($this->minOccur) {
45 Schema => $this 46 # we don't have a value but it's a mandatory property
46 ); 47 return new IMPL::DOM::Schema::ValidationError(
47 } 48 Message => $this->RequiredMessage,
48 return $this->SUPER::Validate($nodeProp); 49 Node => $node,
49 } else { 50 Schema => $this
50 return (); 51 );
51 } 52 }
53
52 } 54 }
53 55
54 1; 56 1;