Mercurial > pub > Impl
view Lib/Form/Filter/Mandatory.pm @ 54:f4e045e47770
commit
author | wizard@linux-odin.local |
---|---|
date | Tue, 02 Mar 2010 20:15:57 +0300 |
parents | 16ada169ca75 |
children | 76515373dac0 |
line wrap: on
line source
package Form::Filter::Mandatory; use strict; use Common; use base qw(Form::Filter); sub SUPPORTED_CONTEXT { Form::Filter::CTX_SINGLE | Form::Filter::CTX_SET } sub Invoke { my ($this,$target,$context,$schemaTarget,$parent) = @_; my @list; if ($context & Form::Filter::CTX_SET) { @list = @{$target || []}; } elsif ($context & (Form::Filter::CTX_SINGLE | Form::Filter::CTX_EXISTENT)) { @list = ($target); } foreach my $object (@list) { if (defined $object and not $object->isEmpty) { return Form::FilterResult->new( State => Form::FilterResult::STATE_SUCCESS_STAY ); } } return Form::FilterResult->new( State => Form::FilterResult::STATE_ERROR, Message => $this->FormatMessage($schemaTarget), Target => $schemaTarget, Container => $parent ); } 1;