X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=blobdiff_plain;f=FS%2FFS%2Fpart_pkg.pm;h=709e137f373f92f092f6136cb4fd923a2e883431;hp=9ed623f659300f2972a36abfad906681d428e8c1;hb=c894ab1b3132128b297d7fb556882c1753ef80ec;hpb=fdb8784fc81fc5c809a8c2e495a9dfa5b30f0d91 diff --git a/FS/FS/part_pkg.pm b/FS/FS/part_pkg.pm index 9ed623f65..709e137f3 100644 --- a/FS/FS/part_pkg.pm +++ b/FS/FS/part_pkg.pm @@ -770,6 +770,32 @@ sub check { ''; } +=item check_options + +For a passed I<$options> hashref, validates any options that +have 'validate' subroutines defined (I<$options> values might +be altered.) Returns error message, or empty string if valid. + +Invoked by L and L via the equivalent +methods in L. + +=cut + +sub check_options { + my ($self,$options) = @_; + foreach my $option (keys %$options) { + if (exists $plans{ $self->plan }->{fields}->{$option}) { + if (exists($plans{$self->plan}->{fields}->{$option}->{'validate'})) { + # pass option name for use in error message + # pass a reference to the $options value, so it can be cleaned up + my $error = &{$plans{$self->plan}->{fields}->{$option}->{'validate'}}($option,\($options->{$option})); + return $error if $error; + } + } # else "option does not exist" error? + } + return ''; +} + =item check_pkg_svc Checks pkg_svc records as a whole (for part_svc_link dependencies).