Mercurial > pub > Impl
view Lib/IMPL/DOM/Schema/Validator/RegExp.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 | df6b4f054957 |
children | 196bf443b5e1 |
line wrap: on
line source
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;