X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2Fpart_pkg.pm;h=4aa2926c44ea72a51a8e85834f310653e11c2abe;hb=d5d62e40593d5153afd64527accad35b7f4fda2e;hp=4492c40231e02decdeba959a8800b5980a9db2ff;hpb=81e69f7d093e9df23e814e15ed35b6c6e6545ae7;p=freeside.git diff --git a/FS/FS/part_pkg.pm b/FS/FS/part_pkg.pm index 4492c4023..4aa2926c4 100644 --- a/FS/FS/part_pkg.pm +++ b/FS/FS/part_pkg.pm @@ -693,6 +693,25 @@ sub replace { ''; } +sub validate_number { + my ($option, $valref) = @_; + + $$valref = 0 unless $$valref; + return "Invalid $option" + unless ($$valref) = ($$valref =~ /^\s*(\d+)\s*$/); + return ''; +} + +sub validate_number_blank { + my ($option, $valref) = @_; + + if ($$valref) { + return "Invalid $option" + unless ($$valref) = ($$valref =~ /^\s*(\d+)\s*$/); + } + return ''; +} + =item check Checks all fields to make sure this is a valid package definition. If @@ -786,11 +805,17 @@ sub check { =item check_options -For a passed I<$options> hashref, validates any options that -have 'validate' subroutines defined in the info hash, -then validates the entire hashref if the price plan has -its own 'validate' subroutine defined in the info hash -(I<$options> values might be altered.) +Pass an I<$options> hashref that contains the values to be +inserted or updated for any FS::part_pkg::MODULE.pm. + +For each key in I<$options>, validates the value by calling +the 'validate' subroutine defined for that option e.g. +FS::part_pkg::MODULE::plan_info()->{$KEY}->{validate}. The +option validation function is only called when the hashkey for +that option exists in I<$options>. + +Then the module validation function is called, from +FS::part_pkg::MODULE::plan_info()->{validate} Returns error message, or empty string if valid. @@ -2596,4 +2621,3 @@ schema.html from the base documentation. =cut 1; -