Mercurial > pub > Impl
diff 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 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Lib/IMPL/DOM/Schema/Validator/RegExp.pm Thu May 06 00:54:17 2010 +0400 @@ -0,0 +1,37 @@ +package IMPL::DOM::Schema::Validator::RegExp; + +use base qw(IMPL::DOM::Schema::Validator); + +our %CTOR = ( + 'IMPL::DOM::Schema::Validator' => sub { + my %args = @_; + $args{nodeName} ||= 'RegExp'; + %args; + } +); + +use IMPL::Class::Property; + +BEGIN { + public property message => prop_all; +} + +sub CTOR { + my ($this) = @_; + + $this->message("A %Node.nodeName% doesn't match to the format %Schema.name%"); +} + +sub Validate { + my ($this,$node) = @_; + + my $rx = $this->nodeValue; + return new IMPL::DOM::Schema::ValidationError( + Node => $node, + Source => $this, + Schema => $this->parentNode, + Message => $this->message + ) unless (not $node->isComplex) and $node->nodeValue =~ /$rx/; +} + +1; \ No newline at end of file