Skip to content

Commit

Permalink
Merge pull request #8 from KaririCode-Framework/develop
Browse files Browse the repository at this point in the history
fix(validator): resolve processor state retention issues
  • Loading branch information
walmir-silva authored Oct 24, 2024
2 parents 6bc3e74 + dfd371c commit 58a25f3
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 15 deletions.
28 changes: 14 additions & 14 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 9 additions & 1 deletion src/ProcessorPipeline.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

use KaririCode\Contract\Processor\Pipeline;
use KaririCode\Contract\Processor\Processor;
use KaririCode\Contract\Processor\ValidatableProcessor;

class ProcessorPipeline implements Pipeline
{
Expand All @@ -22,7 +23,14 @@ public function process(mixed $input): mixed
{
return array_reduce(
$this->processors,
fn ($carry, Processor $processor) => $processor->process($carry),
static function ($carry, Processor $processor): mixed {
// Reset the processor's state if it's a ValidatableProcessor
if ($processor instanceof ValidatableProcessor) {
$processor->reset();
}

return $processor->process($carry);
},
$input
);
}
Expand Down

0 comments on commit 58a25f3

Please sign in to comment.