MT#65618 require contract/subscriber sections in prov templates

Validate that dependent template sections only appear together with
their parent contract or subscriber section.

Change-Id: I3150ca1844b633ab80ffd501fcf587d08f9ebdf8
master
Rene Krenn 2 days ago
parent cc34719693
commit 22623e7c2f

@ -151,12 +151,13 @@ sub validate_template {
my ($data,$prefix) = @_;
$prefix //= 'template: ';
die($prefix . "not a hash\n") unless 'HASH' eq ref $data;
# todo: validate fields
#foreach my $section (qw/subscriber/) {
# die($prefix . "section '$section' required\n") unless exists $data->{$section};
# die($prefix . "section '$section' is not a hash\n") unless 'HASH' eq ref $data->{$section};
#}
if (grep { exists $data->{$_} } qw(contract_balance fraud_preferences contract_preferences)) {
die($prefix . "section 'contract' required\n") unless exists $data->{contract};
}
if (grep { exists $data->{$_} } qw(subscriber_preferences registrations trusted_sources cf_mappings)) {
die($prefix . "section 'subscriber' required\n") unless exists $data->{subscriber};
}
}

Loading…
Cancel
Save