Add a method that returns the regexp used to validate generated GUIDs. This should
prevent the regexp from proliferating all through tests and code. Also, add a test for the method, which just checks that it returns a regexp.
This commit is contained in:
parent
f56c0873d8
commit
fca9e9c633
2 changed files with 19 additions and 2 deletions
|
|
@ -20,6 +20,7 @@ use Digest::MD5;
|
|||
use Time::HiRes qw( gettimeofday usleep );
|
||||
use MIME::Base64;
|
||||
|
||||
my $idValidator = qr/^[A-Za-z0-9_-]{22}$/;
|
||||
|
||||
=head1 NAME
|
||||
|
||||
|
|
@ -55,6 +56,19 @@ sub DESTROY {
|
|||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getValidator
|
||||
|
||||
Get the regular expression used to validate generated GUIDs. This is just to prevent
|
||||
regular expressions from being duplicated all over the place.
|
||||
|
||||
=cut
|
||||
|
||||
sub getValidator {
|
||||
return $idValidator;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 generate
|
||||
|
|
@ -137,7 +151,7 @@ Returns true if $idString is a valid WebGUI guid.
|
|||
|
||||
sub valid {
|
||||
my ($self, $idString) = @_;
|
||||
return $idString =~ m/^[A-Za-z0-9_-]{22}$/;
|
||||
return $idString =~ m/$idValidator/;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue