Skip to content

Line number for validation issue is not correct when error happens in a step processed before the validator #307

@ghost

Description

Fount the issue when using both a pre filter, then running converters and mapping, then running a post filter.

Can be reproduced with:
$reader = new ArrayReader([['id'=>1],['id'=>2]]);
$workflow = new StepAggregator($reader);
$workflow->setSkipItemOnFailure(true);
$validator = $this->getContainer()->get('validator');
$preFilter = new ValidatorFilter($validator);
$preFilter->throwExceptions(false);
$preFilter->add('id', new Assert\EqualTo(['value'=>2]));
$postFilter = new ValidatorFilter($validator);
$postFilter->throwExceptions(false);
$postFilter->add('id', new Assert\EqualTo(['value'=>1]));
$workflow->addStep((new FilterStep())->add($preFilter),2);
$workflow->addStep((new FilterStep())->add($postFilter),1);
$workflow->process();
var_dump(array_keys($postFilter->getViolations()), array_keys($postFilter->getViolations()));

Returns:

array(1) {
[0]=>
int(1)
}
array(1) {
[0]=>
int(1)
}

Expected:

array(1) {
[0]=>
int(1)
}
array(1) {
[0]=>
int(2)
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions