App-Office-Contacts

 view release on metacpan or  search on metacpan

lib/App/Office/Contacts/Util/Validator.pm  view on Meta::CPAN

	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.

# --------------------------------------------------

sub validate_organization_id
{
	my($self) = @_;

	$self -> app -> log(debug => 'Util::Validator.validate_organization_id()');

	my($verifier) = Data::Verifier -> new
	(
		filters => [qw(trim)],
		profile =>
		{
			organization_id =>
			{
				post_check => sub {return $self -> db -> library -> validate_id('organizations', shift -> get_value('organization_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 validate_organization_id.

# --------------------------------------------------

sub validate_person_id
{
	my($self) = @_;

	$self -> app -> log(debug => 'Util::Validator.validate_person_id()');

	my($verifier) = Data::Verifier -> new
	(
		filters => [qw(trim)],
		profile =>
		{
			person_id =>
			{
				post_check => sub {return $self -> db -> library -> validate_id('people', shift -> get_value('person_id') )},
				required   => 1,
				type       => 'Int',
			},
			sid =>
			{
				post_check => sub {return $self -> check_sid(shift -> get_value('sid') )},
				required   => 1,

lib/App/Office/Contacts/Util/Validator.pm  view on Meta::CPAN


=head2 clean_user_data()

=head2 config()

Retturns a hashref of config items passed in to new().

=head2 db()

Returns an instance of a L<App::Office::Contacts::Database>-based object passed in to new().

=head2 delete_note()

Validates CGI form parameters when deleting a Note.

=head2 delete_occupation()

Validates CGI form parameters when deleting an Occupation.

=head2 delete_staff()

Validates CGI form parameters when deleting a Staff member.

=head2 find_organization()

=head2 find_person()

=head2 log_result($result)

=head2 organization_profile()

=head2 person_profile()

=head2 query()

Returns the L<CGI>-style object passed in to new().

=head2 report()

=head2 update_note()

Validates CGI form parameters when updating a Note.

=head2 update_organization()

Validates CGI form parameters when updating an Organization.

=head2 update_person()

Validates CGI form parameters when updating a Person.

=head2 validate_organization_id()

Validates just the organization_id and the sid (Session Id within L<Data::Session> within
L<App::Office::Contacts::Database>).

=head2 validate_person_id()

Validates just the person_id and the sid (See L<App::Office::Contacts::Controller::Exporter::Person>).

=head2 validate_upload()

Validates CGI form parameters when uploading a file (see L<App::Office::Contacts::Import::vCards>).

=head1 FAQ

See L<App::Office::Contacts/FAQ>.

=head1 Support

See L<App::Office::Contacts/Support>.

=head1 Author

C<App::Office::Contacts> was written by Ron Savage I<E<lt>ron@savage.net.auE<gt>> in 2013.

L<Home page|http://savage.net.au/index.html>.

=head1 Copyright

Australian copyright (c) 2013, Ron Savage.
	All Programs of mine are 'OSI Certified Open Source Software';
	you can redistribute them and/or modify them under the terms of
	The Artistic License V 2, a copy of which is available at:
	http://www.opensource.org/licenses/index.html

=cut



( run in 0.696 second using v1.01-cache-2.11-cpan-b16cb0d3907 )