You could build a hash of regexes, something like this (the regexes are just given as quick simplistic examples, I haven't thought very carefully about them).
my %validate = ( INT => qr /^[+-]?\d+$/, DEC => qr /^[+-]?\d*\.?\d*$/, #etc. );
and then use it to validate your individual fields.
You might actually take it one step further and build a dispatch table, something like this:
my %actions = ( INT => sub { return 1 if $_[0] =~ /^[+-]?\d+$/}, DEC => sub { return 1 if $_[0] =~ /^[+-]?\d*\.?\d*$/}, VARCHAR(5)=> \&validate_varchar_5(@_), #etc. );
This is a very rough untested example, I just want to convey the general idea.
You don't say enough about what you have done to figure out whether these techniques will be beneficial.
In reply to Re: Efficient way to do field validation
by Laurent_R
in thread Efficient way to do field validation
by govindkailas
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |