From 0bfed40748e5a26e381aff78bb1efc2a58d7f15f Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Fri, 2 Oct 2020 13:29:19 -0400 Subject: [PATCH] LPXXX Support stacked A/T Validators Action/Trigger validators can now be configured with comma-separated strings to support stacked validators. Signed-off-by: Bill Erickson --- .../lib/OpenILS/Application/Trigger/Event.pm | 36 +++++++++++++++------- 1 file changed, 25 insertions(+), 11 deletions(-) diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Trigger/Event.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Trigger/Event.pm index 4291eeb407..8fd6f18cc8 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Trigger/Event.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Trigger/Event.pm @@ -244,17 +244,31 @@ sub validate { if ($self->build_environment->environment->{complete}) { $self->update_state( 'validating') || die 'Unable to update event state'; - try { - $self->valid( - OpenILS::Application::Trigger::ModRunner::Validator - ->new( $self->event->event_def->validator, $self->environment ) - ->run - ->final_result - ); - } otherwise { - $log->error("Event validation failed with ". shift() ); - $self->update_state( 'error' ) || die 'Unable to update event state'; - }; + + my @validators = split(',', $self->event->event_def->validator); + + my $valid; + for my $validator (@validators) { + + eval { + $valid = + OpenILS::Application::Trigger::ModRunner::Validator + ->new( $validator, $self->environment ) + ->run + ->final_result + }; + + if ($@) { + $log->error("Event validation [$validator] failed with: $@"); + $self->update_state('error') || die 'Unable to update event state'; + $valid = undef; + }; + + # Stop on first failed validator. + last unless $valid; # 0 or undef + } + + $self->valid($valid); if (defined $self->valid) { if ($self->valid) { -- 2.11.0