Mercurial > pub > Impl
diff Lib/Form/ValueItem.pm @ 49:16ada169ca75
migrating to the Eclipse IDE
author | wizard@linux-odin.local |
---|---|
date | Fri, 26 Feb 2010 10:49:21 +0300 |
parents | 03e58a454b20 |
children | 76515373dac0 |
line wrap: on
line diff
--- a/Lib/Form/ValueItem.pm Fri Feb 26 01:43:42 2010 +0300 +++ b/Lib/Form/ValueItem.pm Fri Feb 26 10:49:21 2010 +0300 @@ -1,47 +1,47 @@ -package Form::ValueItem; -use strict; -use base qw(Form::Item); -use Common; -use Form::Filter; - -BEGIN { - DeclareProperty Value => ACCESS_ALL; - DeclareProperty Type => ACCESS_READ; - DeclareProperty Schema => ACCESS_READ; -} - -sub CTOR { - my ($this,%args) = @_; - - $this->SUPER::CTOR(@args{qw(Id Form Parent Attributes)}); - $this->{$Type} = $args{'Type'}; - $this->{$Schema} = $args{'Schema'} or die new Exception('A field schema is required'); -} - -sub isEmpty { - my ($this) = @_; - - return length $this->{$Value} ? 0 : 1; -} - -sub Validate { - my ($this,$rhDisableFilters) = @_; - - $rhDisableFilters ||= {}; - - my @errors; - - foreach my $filter (grep {$_->SUPPORTED_CONTEXT & (Form::Filter::CTX_SINGLE) and not exists $rhDisableFilters->{$_}} map {$_->Instance} $this->{$Schema}->Filters) { - my $result = $filter->Invoke($this,Form::Filter::CTX_SINGLE | Form::Filter::CTX_EXISTENT,$this->{$Schema},$this->Parent); - if ($result->State == Form::FilterResult::STATE_SUCCESS_STOP) { - return (); - } elsif ($result->State == Form::FilterResult::STATE_ERROR) { - push @errors,$result; - } - } - - return @errors; -} - - -1; +package Form::ValueItem; +use strict; +use base qw(Form::Item); +use Common; +use Form::Filter; + +BEGIN { + DeclareProperty Value => ACCESS_ALL; + DeclareProperty Type => ACCESS_READ; + DeclareProperty Schema => ACCESS_READ; +} + +sub CTOR { + my ($this,%args) = @_; + + $this->SUPER::CTOR(@args{qw(Id Form Parent Attributes)}); + $this->{$Type} = $args{'Type'}; + $this->{$Schema} = $args{'Schema'} or die new Exception('A field schema is required'); +} + +sub isEmpty { + my ($this) = @_; + + return length $this->{$Value} ? 0 : 1; +} + +sub Validate { + my ($this,$rhDisableFilters) = @_; + + $rhDisableFilters ||= {}; + + my @errors; + + foreach my $filter (grep {$_->SUPPORTED_CONTEXT & (Form::Filter::CTX_SINGLE) and not exists $rhDisableFilters->{$_}} map {$_->Instance} $this->{$Schema}->Filters) { + my $result = $filter->Invoke($this,Form::Filter::CTX_SINGLE | Form::Filter::CTX_EXISTENT,$this->{$Schema},$this->Parent); + if ($result->State == Form::FilterResult::STATE_SUCCESS_STOP) { + return (); + } elsif ($result->State == Form::FilterResult::STATE_ERROR) { + push @errors,$result; + } + } + + return @errors; +} + + +1;