From 8e554db2f70c1f06cde68c138b549061514e5fdb Mon Sep 17 00:00:00 2001 From: Christopher Burger Date: Wed, 9 Jan 2019 12:28:19 -0500 Subject: RT# 81249 - added ability to validate price plan option fields Conflicts: httemplate/edit/part_pkg.cgi --- FS/FS/part_pkg.pm | 8 ++++++++ FS/FS/part_pkg/voip_cdr.pm | 4 ++++ FS/FS/part_pkg/voip_inbound.pm | 4 ++++ 3 files changed, 16 insertions(+) (limited to 'FS') diff --git a/FS/FS/part_pkg.pm b/FS/FS/part_pkg.pm index cad761498..78f5dc097 100644 --- a/FS/FS/part_pkg.pm +++ b/FS/FS/part_pkg.pm @@ -583,6 +583,14 @@ sub replace { ''; } +sub validate_number { + my ($option, $valref) = @_; + $$valref = 0 unless $$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 diff --git a/FS/FS/part_pkg/voip_cdr.pm b/FS/FS/part_pkg/voip_cdr.pm index 342f27255..3a6315910 100644 --- a/FS/FS/part_pkg/voip_cdr.pm +++ b/FS/FS/part_pkg/voip_cdr.pm @@ -173,9 +173,13 @@ tie my %accountcode_tollfree_field, 'Tie::IxHash', }, 'use_cdrtypenum' => { 'name' => 'Only charge for CDRs where the CDR Type is set to this cdrtypenum: ', + 'validate' => \&FS::part_pkg::validate_number, + 'js_validate' => 'digits', }, 'ignore_cdrtypenum' => { 'name' => 'Do not charge for CDRs where the CDR Type is set to this cdrtypenum: ', + 'validate' => \&FS::part_pkg::validate_number, + 'js_validate' => 'digits', }, 'use_calltypenum' => { 'name' => 'Only charge for CDRs where the CDR Call Type is set to this calltypenum: ', diff --git a/FS/FS/part_pkg/voip_inbound.pm b/FS/FS/part_pkg/voip_inbound.pm index 6af6dc375..22ca79694 100644 --- a/FS/FS/part_pkg/voip_inbound.pm +++ b/FS/FS/part_pkg/voip_inbound.pm @@ -64,9 +64,13 @@ tie my %granularity, 'Tie::IxHash', FS::rate_detail::granularities(); }, 'use_cdrtypenum' => { 'name' => 'Only charge for CDRs where the CDR Type is set to this cdrtypenum: ', + 'validate' => \&FS::part_pkg::validate_number, + 'js_validate' => 'digits', }, 'ignore_cdrtypenum' => { 'name' => 'Do not charge for CDRs where the CDR Type is set to this cdrtypenum: ', + 'validate' => \&FS::part_pkg::validate_number, + 'js_validate' => 'digits', }, 'use_calltypenum' => { 'name' => 'Only charge for CDRs where the CDR Call Type is set to this cdrtypenum: ', -- cgit v1.2.1