I'm currently working on a field value validation system. It takes in a
custom data type, and then runs each key through a switch statement and
validates the value.

As I add new data types, I run the type through the switch, to ensure
all fields are tested. When they are not, I classify them within the
appropriate case statement. For example:

# STRINGS
case /^(comment|plan_type|description|desc|started|
        billing_address1|billing_address2|shipping_address1|
        shipping_address2|billing_company_name|shipping_company_name|
        shipping_town|billing_town)$/x

        {
             if ($self->safe_string($value)) {
                 $error->add_message( "$attribute contains bad char " .
                        $self->safe_string($value)
                 );
             }
}

This is becoming extremely boring and tedious, as I have eight or nine
similar but different case statements. I haven't been able to figure out
a way to do this that will save me any time or work. Any suggestions on
how I can classify the keys in a better (ie less boring and eye popping)
way?

Steve

Attachment: smime.p7s
Description: S/MIME Cryptographic Signature

Reply via email to