chromatic > CGI-Untaint-boolean-1.01 > CGI::Untaint::boolean

Download:
CGI-Untaint-boolean-1.01.tar.gz

Dependencies

Annotate this POD

CPAN RT

Open  0
View/Report Bugs
Module Version: 1.01   Source  

NAME ^

CGI::Untaint::boolean - untaint boolean values from CGI programs

SYNOPSIS ^

  use CGI::Untaint;

  my $handler = CGI::Untaint->new( $q->Vars() );
  my $boolean = $handler->extract( -as_boolean => 'some_feature' );

DESCRIPTION ^

This input handler verifies that it is dealing with a reasonable boolean value, probably from a checkbox with no value specified. In this case, "reasonable" means that the value is on, if the checkbox is checked, or empty, if the client did not send a value.

Note: the value() method will return either true or false. It will not return the string "on" or the empty string. It's boolean for a reason! (Don't count on it returning 0 for false either; false is just false.)

METHOD ^

is_valid()

Returns true if the value for this checkbox is valid, setting the value to true if the value is on, false otherwise.

SEE ALSO ^

CGI::Untaint, CGI::Untaint::object

AUTHOR ^

chromatic, chromatic at wgz dot org

Thanks to Tony Bowden for helpful suggestions, Simon Wilcox for reporting a false value bug, with a test patch, and Dave Wilcox for helping to disambiguate the documentation.

BUGS ^

No known bugs. Please report any to http://rt.cpan.org/.

COPYRIGHT ^

Copyright (c) 2004 - 2005, chromatic. All rights reserved. You may use, modify, and distribute this module under the same terms as Perl 5.8.x itself, in the hope that it is useful but certainly under no guarantee.

syntax highlighting: