Skip Menu |

Preferred bug tracker

Please visit the preferred bug tracker to report your issue.

This queue is for tickets about the Crypt-Cracklib CPAN distribution.

Report information
The Basics
Id: 62270
Status: resolved
Priority: 0/
Queue: Crypt-Cracklib

People
Owner: Nobody in particular
Requestors: ARISTOTLE [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Wishlist
Broken in: (no value)
Fixed in: (no value)



Subject: Add a "bad_pass" wrapper function
The notion of a true value in Perl (any defined value except 0, the string '0' and the empty string) is well suited for an all-in-one interface in this module but neither of the existing wrapper functions makes use of that. Really, pretty much all that has to be done is to expose _FascistCheck almost directly. Something like this: sub bad_pass { my ($password, $dict) = @_; return 'Password is all whitespace' if $password !~ /\S/; return _FascistCheck($password, $dict || $DEFAULT_DICT); } Then user code can do something like this: if (my $reason = bad_pass $password) { print "Bad password! ($reason)\n"; print "No cookie!\n"; } else { ... } instead of having to use this cumbersome conditional: if ((my $reason = bad_pass $password) ne 'ok') { (or checking the password twice). Thanks.
Please see the check() function that is already provided by the module. --dan
Please read more carefully. The `check` function does *not* provide what I am asking for, it only returns a boolean. I am asking for a function that returns either a reason string or an empty string, because such a return value can do double duty as a boolean flag. The string "ok" has the same truthiness as any reason string (they're all true), so the value returned from `fascist_check` is not usable as a boolean flag. The value returned from `check` OTOH is a boolean flag and not usable as a reason string. The function I proposed would return a reason on failure (a true value) but an empty string or undef on pass (a false value). So the same value can be used as both a boolean and a reason string.
I apologize, it's a little too early in the morning for me to be reading email.
Added in v1.6