The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

PSGI::Hector::Request - Form request class

SYNOPSIS

my $r = $hector->getRequest();
my $params = $r->getParameters();

DESCRIPTION

Class to deal with the current page request

METHODS

getParameters()

my $params = $r->getParameters();

Returns a hash reference of all the GET/POST values from the current request.

Parameters that have multiple values will be returned as an array reference.

validate()

my $rules = {
	'age' => {
		'rule' => '^\d+$',
		'friendly' => 'Your Age'
	}
};	#the form validation rules
my($result, $errors) = $r->validate($rules);

Validates all the current form fields against the provided hash reference.

The hash reference contains akey for every field you are concerned about, which is a reference to another hash containing two elements. The first is the actaul matching rule. The second is the friendly name for the field used in the error message, if a problem with the field is found.

The method returns two values, first being a 0 or a 1 indicating the success of the form. The second is a reference to a list of errors if any.

getHeader($header)

$request->getHeader($name)

Returns the value of the specified request header.

Notes

Author

MacGyveR <dumb@cpan.org>

Development questions, bug reports, and patches are welcome to the above address

See Also

Copyright

Copyright (c) 2017 MacGyveR. All rights reserved.

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.