Business-AU-Ledger
view release on metacpan or search on metacpan
lib/Business/AU/Ledger/Util/Validate.pm view on Meta::CPAN
package Business::AU::Ledger::Util::Validate;
use Data::FormValidator;
use Data::FormValidator::Constraints qw/:closures/;
use Moose;
use Regexp::Common qw/number/;
has db => (is => 'rw', isa => 'Business::AU::Ledger::Database');
has query => (is => 'rw', isa => 'CGI');
use namespace::autoclean;
our $myself;
our $VERSION = '0.88';
# -----------------------------------------------
sub BUILD
{
my($self) = @_;
$myself = $self;
} # End of BUILD.
# -----------------------------------------------
sub clean_user_data
{
my($data, $max_length) = @_;
my($integer) = 0;
$data = '' if (! defined($data) || (length($data) == 0) || (length($data) > $max_length) );
$data = '' if ($data =~ /<script\s*>.+<\s*\/?\s*script\s*>/i); # http://www.perl.com/pub/a/2002/02/20/css.html.
$data = '' if ($data =~ /<(.+)\s*>.*<\s*\/?\s*\1\s*>/i); # Ditto, but much more strict.
$data =~ s/^\s+//;
$data =~ s/\s+$//;
$data = 0 if ($integer && (! $data || ($data !~ /^[0-9]+$/) ) );
return $data;
} # End of clean_user_data.
# --------------------------------------------------
sub filter_initialize
{
my($value) = @_;
$value =~ s/^Initialize\s//;
return $value;
} # End of filter_initialize.
# --------------------------------------------------
sub fix_double_quotes
{
my($value) = @_;
$value =~ tr/"/'/;
return $value;
} # End of fix_double_quotes.
# --------------------------------------------------
sub initialize_payments
{
my($self) = @_;
return Data::FormValidator -> check($self -> query, $self -> initialize_payments_profile);
( run in 0.710 second using v1.01-cache-2.11-cpan-5b529ec07f3 )