comparison Lib/IMPL/DOM/Schema/Property.pm @ 21:fafe56cfcd69

temp commit
author Sergey
date Wed, 30 Sep 2009 10:25:41 +0400
parents
children 7f00786f8210
comparison
equal deleted inserted replaced
20:267460284fb3 21:fafe56cfcd69
1 package IMPL::DOM::Schema::Property;
2 use strict;
3 use warnings;
4
5 use base qw(IMPL::DOM::Schema::SimpleNode);
6 require IMPL::DOM::Schema;
7 require IMPL::DOM::Node;
8 use IMPL::Class::Property;
9
10 __PACKAGE__->PassThroughArgs;
11
12 BEGIN {
13 public property RequiredMessage => prop_all;
14 }
15
16 our %CTOR = {
17 'IMPL::DOM::Schema::SimleNode' => sub {
18 my %args = @_;
19
20 $args{maxOccur} = 1;
21 $args{minOccur} = delete $args{optional} ? 0 : 1;
22 $args{nodeName} ||= 'Property';
23
24 return %args;
25 }
26 };
27
28 sub CTOR {
29 my ($this,%args) = @_;
30
31 $this->RequiredMessage($args{RequiredMessage} || 'A property %Schema.name% is required');
32 }
33
34 sub Validate {
35 my ($this,$node) = @_;
36
37 if ($this->minOccur) {
38 my $prop = $this->name;
39 my $nodeProp = new IMPL::DOM::Node(nodeName => '::property', nodeValue => $node->$prop() || $node->nodePropety($prop));
40
41 if (! $nodeProp->nodeValue) {
42 return new IMPL::DOM::Schema::VaidationError(
43 Message =>
44 );
45 }
46 return $this->SUPER::Validate($nodeProp);
47 } else {
48 return ();
49 }
50 }
51
52 1;