49
|
1 package Form::Filter::Mandatory;
|
|
2 use strict;
|
|
3 use Common;
|
|
4 use base qw(Form::Filter);
|
|
5
|
|
6 sub SUPPORTED_CONTEXT { Form::Filter::CTX_SINGLE | Form::Filter::CTX_SET }
|
|
7
|
|
8 sub Invoke {
|
|
9 my ($this,$target,$context,$schemaTarget,$parent) = @_;
|
|
10
|
|
11 my @list;
|
|
12 if ($context & Form::Filter::CTX_SET) {
|
|
13 @list = @{$target || []};
|
|
14 } elsif ($context & (Form::Filter::CTX_SINGLE | Form::Filter::CTX_EXISTENT)) {
|
|
15 @list = ($target);
|
|
16 }
|
|
17
|
|
18 foreach my $object (@list) {
|
|
19 if (defined $object and not $object->isEmpty) {
|
|
20 return Form::FilterResult->new(
|
|
21 State => Form::FilterResult::STATE_SUCCESS_STAY
|
|
22 );
|
|
23 }
|
|
24 }
|
|
25
|
|
26 return Form::FilterResult->new(
|
|
27 State => Form::FilterResult::STATE_ERROR,
|
|
28 Message => $this->FormatMessage($schemaTarget),
|
|
29 Target => $schemaTarget,
|
|
30 Container => $parent
|
|
31 );
|
|
32 }
|
|
33
|
|
34 1;
|