[Date Prev][Date Next][Thread Prev][Thread Next][Minivend by date
][Minivend by thread
]
Re: [mv] PATCH: Testing States and Provinces...
****** message to minivend-users from Mike Heins <mikeh@minivend.com> ******
Quoting Jeff Carnahan (jcarnahan@networq.com):
>
> It seems that the state and province (and state_province) order profile
> checks don't properly handle blank test situations. If a user leaves the
> state (or province) field empty, the check will succeed. The patch (against
> MV 4.04A) corrects this by ensuring that the user actually entered data into
> the field being checked.
>
Thanks for the heads up -- I have changed the code to be as below. The
error was "$state =~ /\S/" instead of $val =~ /\S/ as I had intended.
my $state = <<EOF;
| AL AK AZ AR CA CO CT DE FL GA HI ID IL IN IA KS KY LA ME MD |
| MA MI MN MS MO MT NE NV NH NJ NM NY NC ND OH OK OR PA PR RI |
| SC SD TN TX UT VT VA WA WV WI WY DC AP FP FPO APO GU VI AS |
EOF
my $province = <<EOF;
| AB BC MB NB NF NS NT ON PE QC SK YT YK |
EOF
sub _state_province {
my($ref,$var,$val) = @_;
$province = " $::Variable->{MV_VALID_PROVINCE} "
if defined $::Variable->{MV_VALID_PROVINCE};
$state = " $::Variable->{MV_VALID_STATE} "
if defined $::Variable->{MV_VALID_STATE};
if( $val =~ /\S/ and ($state =~ /\s$val\s/i or $province =~ /\s$val\s/i) ) {
return (1, $var, '');
}
else {
return (undef, $var, "'$val' not a two-letter state or province code");
}
}
sub _state {
my($ref,$var,$val) = @_;
$state = " $::Variable->{MV_VALID_STATE} "
if defined $::Variable->{MV_VALID_STATE};
if( $val =~ /\S/ and $state =~ /\s$val\s/i ) {
return (1, $var, '');
}
else {
return (undef, $var, "'$val' not a two-letter state code");
}
}
sub _province {
my($ref,$var,$val) = @_;
$province = " $::Variable->{MV_VALID_PROVINCE} "
if defined $::Variable->{MV_VALID_PROVINCE};
if( $val =~ /\S/ and $province =~ /\s$val\s/i) {
return (1, $var, '');
}
else {
return (undef, $var, "'$val' not a two-letter province code");
}
}
Akopia, Inc., 131 Willow Lane, Floor 2, Oxford, OH 45056
phone +1.513.523.8220 fax 7501 <heins@akopia.com>
Be patient. God isn't finished with me yet. -- unknown
-
To unsubscribe from the list, DO NOT REPLY to this message. Instead, send
email with 'UNSUBSCRIBE minivend-users' in the body to Majordomo@minivend.com.
Archive of past messages: http://www.minivend.com/minivend/minivend-list