Mercurial > pub > Impl
view Lib/IMPL/DOM/Schema/Validator/RegExp.pm @ 250:129e48bb5afb
DOM refactoring
ObjectToDOM methods are virtual
QueryToDOM uses inflators
Fixed transform for the complex values in the ObjectToDOM
QueryToDOM doesn't allow to use complex values (HASHes) as values for nodes (overpost problem)
author | sergey |
---|---|
date | Wed, 07 Nov 2012 04:17:53 +0400 |
parents | b8c724f6de36 |
children | 5aff94ba842f |
line wrap: on
line source
package IMPL::DOM::Schema::Validator::RegExp; use strict; use parent 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; public property launder => prop_all; private property _rx => prop_all; } sub CTOR { my ($this,%args) = @_; $this->message($args{message} || "A %node.nodeName% doesn't match to the format %schema.display%"); } sub Validate { my ($this,$node,$ctx) = @_; my $rx = $this->_rx() || $this->_rx( map qr{$_}, $this->nodeValue ); return new IMPL::DOM::Schema::ValidationError( node => $node, source => $ctx && $ctx->{Source} || $this->parentNode, schema => $this->parentNode, message => $this->message ) unless (not $node->isComplex) and $node->nodeValue =~ /($rx)/; $node->nodeValue($1) if $this->launder; return (); } 1;