view 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 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;