App-Office-Contacts
view release on metacpan or search on metacpan
lib/App/Office/Contacts/Util/Validator.pm view on Meta::CPAN
{
post_check => sub {return shift -> get_value('ignore_gender') =~ /^[01]$/ ? 1 : 0},
required => 0,
type => 'Int',
},
ignore_role =>
{
post_check => sub {return shift -> get_value('ignore_role') =~ /^[01]$/ ? 1 : 0},
required => 0,
type => 'Int',
},
ignore_visibility =>
{
post_check => sub {return shift -> get_value('ignore_visibility') =~ /^[01]$/ ? 1 : 0},
required => 0,
type => 'Int',
},
report_id =>
{
post_check => sub {return $self -> db -> library -> validate_id('reports', shift -> get_value('report_id') )},
required => 1,
type => 'Int',
},
report_entity_id =>
{
post_check => sub {return $self -> db -> library -> validate_id('report_entities', shift -> get_value('report_entity_id') )},
required => 1,
type => 'Int',
},
role_id =>
{
post_check => sub {return $self -> db -> library -> validate_id('roles', shift -> get_value('role_id') )},
required => 1,
type => 'Int',
},
sid =>
{
post_check => sub {return $self -> check_sid(shift -> get_value('sid') )},
required => 1,
type => 'Str',
},
visibility_id =>
{
post_check => sub {return $self -> db -> library -> validate_id('visibilities', shift -> get_value('visibility_id') )},
required => 1,
type => 'Int',
},
},
);
my($result) = $verifier -> verify({$self -> query -> Vars});
$self -> log_result($result);
return $result;
} # End of report.
# --------------------------------------------------
sub update_note
{
my($self) = @_;
$self -> app -> log(debug => 'Util::Validator.update_note()');
my($max_note_length) = ${$self -> config}{max_note_length};
my($verifier) = Data::Verifier -> new
(
filters => [qw(trim)],
profile =>
{
entity_id =>
{
post_check => sub {return $self -> check_entity_id(shift)},
required => 1,
type => 'Int',
},
entity_type =>
{
post_check => sub {return shift -> get_value('entity_type') =~ /^(?:organizations|people)/ ? 1 : 0},
required => 1,
type => 'Str',
},
body =>
{
# We can't call clean_user_data() as a filter here,
# because we need to pass in the max length,
# and we can't call it as a post_check, since it
# returns the clean data, not an error flag.
max_length => $max_note_length,
min_length => 0, # Missing means
required => 0, # note is deleted.
type => 'Str',
},
note_id =>
{
required => 1,
type => 'Int',
},
sid =>
{
post_check => sub {return $self -> check_sid(shift -> get_value('sid') )},
required => 1,
type => 'Str',
},
},
);
my($result) = $verifier -> verify({$self -> query -> Vars});
$self -> log_result($result);
return $result;
} # End of update_note.
# --------------------------------------------------
sub update_organization
{
my($self) = @_;
$self -> app -> log(debug => 'Util::Validator.update_organization()');
my($verifier) = Data::Verifier -> new
(
filters => [qw(trim)],
profile =>
{
%{$self -> organization_profile},
organization_id =>
{
post_check => sub {return $self -> check_organization_id(shift -> get_value('organization_id') )},
required => 1,
type => 'Int',
},
},
);
my($result) = $verifier -> verify({$self -> query -> Vars});
$self -> log_result($result);
return $result;
} # End of update_organization.
# --------------------------------------------------
sub update_person
{
my($self) = @_;
$self -> app -> log(debug => 'Util::Validator.update_person()');
my($verifier) = Data::Verifier -> new
(
filters => [qw(trim)],
profile =>
{
%{$self -> person_profile},
person_id =>
{
post_check => sub {return $self -> check_person_id(shift -> get_value('person_id') )},
required => 1,
type => 'Int',
},
},
);
my($result) = $verifier -> verify({$self -> query -> Vars});
$self -> log_result($result);
return $result;
} # End of update_person.
# --------------------------------------------------
sub validate_upload
{
my($self) = @_;
$self -> app -> log(debug => 'Util::Validator.validate_upload()');
my($verifier) = Data::Verifier -> new
(
filters => [qw(trim)],
profile =>
{ # TODO: This is a fake check, for the moment.
sid =>
{
post_check => sub {return 1},
required => 0,
type => 'Str',
},
}
);
my($result) = $verifier -> verify({$self -> query -> Vars});
$self -> log_result($result);
return $result;
} # End of validate_upload.
# --------------------------------------------------
( run in 0.767 second using v1.01-cache-2.11-cpan-99c4e6809bf )