String::Validator::Password - Check a string against a number of common password rules.
Version 0.94
String::Validator::Password is part of the String Validator Collection. It will check a string against any number of password validation rules, and optionally against a second string (as in password confirmation box on a webform). The primary Negative method returns 0 if the password passes all tests, or a string describing the errors if it fails. The Positive Method returns 1 if the string passes and 0 if it fails. The ErrString method returns the errors from the last string processed.
Provides and conforms to all of the standard String::Validator methods, please see String::Validator for general documentation.
SVP knows about four classes of character -- uc (Upper Case), lc (Lower Case), num (Digits), and punct (Everything Else). Types can be required or denied. Thus these 8 arguments require_lc, require_uc, require_nums, require_punct, deny_punct, deny_lc, deny_uc, deny_nums, all of which take a numeric argument, and all of which default to 0 if omitted.
When requiring and denying classes of characters the values of 0 and 1 work as expected, where 0 means not to check this condition at all and 1 means to accept or reject based on the presence of just 1 instance of the type. However, when used to set an amount, require is interpreted as require at least X of this type, while deny is deny if X or more are encountered. require_lc => 2 will result in a string with 2 or more lowercase characters passing the test. deny_lc => 2 will result in a string with 2 lowercase characters being rejected, but would pass a string with 1 lowercase character.
min_types is used to specify the number of different character types required, default is 2.
min_len and max_len determine the respective minimum and maximum length password to accept. Defaults are 6 and 64.
To create a new instance, with all of the default values:
my $Validator = String::Validator::Password->new() ;
Specify all of the default values:
my $Validator = String::Validator::Password->new( require_lc => 0, require_uc => 0, require_punct => 0, require_num => 0, deny_lc => 0, deny_uc => 0, deny_punct => 0, deny_num => 0, min_types => 2, min_len => 6, max_len => 64, ) ; ) ;
Normally you would only specify values that were not the default.
my $Validator = String::Validator::Password->new( require_lc => 2, require_uc => 2, min_types => 3, min_len => 8, max_len => 18, ) ;
Then to check a password you might write something like this:
if( $Validator->IsNot_Valid( $password1, $passwordconfirm ) ) { die $Validator->errstr() ; }
Provide support for custom regexes, custom allow/deny lists, and checking against weak password dictionaries.
John Karr, <brainbuz at brainbuz.org>
<brainbuz at brainbuz.org>
Please report any bugs or feature requests to bug-string-validator-password at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=String-Validator-Password. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
bug-string-validator-password at rt.cpan.org
You can find documentation for this module with the perldoc command.
perldoc Validator
You can also look for information at:
RT: CPAN's request tracker (report bugs here)
http://rt.cpan.org/NoAuth/Bugs.html?Dist=Validator
AnnoCPAN: Annotated CPAN documentation
http://annocpan.org/dist/Validator
CPAN Ratings
http://cpanratings.perl.org/d/Validator
Search CPAN
http://search.cpan.org/dist/Validator/
Copyright 2012 John Karr.
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; version 3 or at your option any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
A copy of the GNU General Public License is available in the source tree; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
To install String::Validator::Password, copy and paste the appropriate command in to your terminal.
cpanm
cpanm String::Validator::Password
CPAN shell
perl -MCPAN -e shell install String::Validator::Password
For more information on module installation, please visit the detailed CPAN module installation guide.