Mercurial > pub > Impl
diff Lib/IMPL/DOM/Schema/Property.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 | c289ed9662ca |
children | 1e7f03414b65 |
line wrap: on
line diff
--- a/Lib/IMPL/DOM/Schema/Property.pm Fri May 07 18:17:40 2010 +0400 +++ b/Lib/IMPL/DOM/Schema/Property.pm Tue May 11 02:42:59 2010 +0400 @@ -10,7 +10,7 @@ __PACKAGE__->PassThroughArgs; BEGIN { - public property RequiredMessage => prop_all; + public property messageRequired => prop_all; } our %CTOR = ( @@ -20,6 +20,7 @@ $args{maxOccur} = 1; $args{minOccur} = delete $args{optional} ? 0 : 1; $args{nodeName} ||= 'Property'; + $args{messageInflateError} ||= "Failed to inflate a property '%Schema.name%' of a node '%Node.path%': %Error.Message%"; return %args; } @@ -28,11 +29,11 @@ sub CTOR { my ($this,%args) = @_; - $this->RequiredMessage($args{RequiredMessage} || 'A property %Schema.name% is required in the %Node.qname%'); + $this->messageRequired($args{messageRequired} || 'A property %Schema.name% is required in the %Node.qname%'); } sub Validate { - my ($this,$node) = @_; + my ($this,$node,$ctx) = @_; my $prop = $this->name; @@ -41,16 +42,17 @@ if ($nodeProp->nodeValue) { # we have a value so validate it - return $this->SUPER::Validate($nodeProp); + return $this->SUPER::Validate($nodeProp,$ctx); } elsif($this->minOccur) { # we don't have a value but it's a mandatory property return new IMPL::DOM::Schema::ValidationError( - Message => $this->RequiredMessage, + Message => $this->messageRequired, Node => $node, - Schema => $this + Schema => $this, + Source => $ctx && $ctx->{Source} || $this ); } - + return (); } 1;