comparison Lib/IMPL/DOM/Schema/Validator/RegExp.pm @ 100:df6b4f054957

Schema in progress Added simple mailer
author wizard
date Thu, 06 May 2010 00:54:17 +0400
parents
children 196bf443b5e1
comparison
equal deleted inserted replaced
99:6dd659f6f66c 100:df6b4f054957
1 package IMPL::DOM::Schema::Validator::RegExp;
2
3 use base qw(IMPL::DOM::Schema::Validator);
4
5 our %CTOR = (
6 'IMPL::DOM::Schema::Validator' => sub {
7 my %args = @_;
8 $args{nodeName} ||= 'RegExp';
9 %args;
10 }
11 );
12
13 use IMPL::Class::Property;
14
15 BEGIN {
16 public property message => prop_all;
17 }
18
19 sub CTOR {
20 my ($this) = @_;
21
22 $this->message("A %Node.nodeName% doesn't match to the format %Schema.name%");
23 }
24
25 sub Validate {
26 my ($this,$node) = @_;
27
28 my $rx = $this->nodeValue;
29 return new IMPL::DOM::Schema::ValidationError(
30 Node => $node,
31 Source => $this,
32 Schema => $this->parentNode,
33 Message => $this->message
34 ) unless (not $node->isComplex) and $node->nodeValue =~ /$rx/;
35 }
36
37 1;