X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2Fpart_pkg.pm;h=915634b948f7b1188a25fe946c1226fb614086ab;hb=9ceca59afe85c259399f77df6f07003f6966b9b9;hp=238c64c9e213806c474cd7dbc459e52dfa1d8fda;hpb=d71e1c5319b4a2f0092f0e64da1638df57162dba;p=freeside.git diff --git a/FS/FS/part_pkg.pm b/FS/FS/part_pkg.pm index 238c64c9e..915634b94 100644 --- a/FS/FS/part_pkg.pm +++ b/FS/FS/part_pkg.pm @@ -669,6 +669,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 supersede OLD [, OPTION => VALUE ... ] Inserts this package as a successor to the package OLD. All options are as