data-import icon indicating copy to clipboard operation
data-import copied to clipboard

ValidatorStep | Can't set option for Constraint Collection allowExtraFields

Open kyleobrien91 opened this issue 8 years ago • 6 comments

Can't currently set flag in ValidatorStep to ignore extra fields in $item object when validating.

@Baachi @ddeboer @sagikazarmark - is this something I can achieve someway else? Otherwise, can I go ahead and create a PR for this?

kyleobrien91 avatar Jun 12 '16 22:06 kyleobrien91

If you deactivate the strict mode, the validator will only validate the fields which have an constraint.

Baachi avatar Jun 13 '16 16:06 Baachi

@Baachi - there is no setStrict on the ValidatorStep class. There is one on the ValidatorFilter but since the Workflow doesn't seem to be a concretion anymore, I can only use steps that implement PriorityStep - whilst my old 'Workflow' object is now a StepAggregator.

Which means I only have ValidatorStep available to me - which doesn't seem to have a setStrict method

https://github.com/ddeboer/data-import/blob/master/src/Step/ValidatorStep.php

kyleobrien91 avatar Jun 13 '16 20:06 kyleobrien91

@Baachi - if I implement the isStrict logic in ValidatorStep as it's done on ValidatorFilter, then setting isStrict(false) works great. Should I push a PR for this or is there a reason this was excluded from ValidatorStep in 0.19.0?

kyleobrien91 avatar Jun 14 '16 11:06 kyleobrien91

Not in the step, but in the ValidatorFilter.

Feel free to open a PR, to implement that feature in the ValidatorStep.

Baachi avatar Jun 14 '16 11:06 Baachi

Thanks @Baachi. One thing - I'm unsure how ValidatorFilter features in the new Workflow. In 0.18 we had a concrete Workflow class. That class had addFilter. However, in 0.19.0, the Workflow class is no longer a concretion. It is now an interface with a single item in the contract that StepAggregator now implements.

StepAggregator itself does not have an addFilter method so it doesn't seem I'm able to leverage the ValidatorFilter in the context of StepAggregator. Further, the filters can't be added as a step because they don't adhere to the Step contract/interface.

Thus, at least, on my first glance, I don't see a way to fit the filters into the "workflow" (ie StepAggregator).

Make sense? Or am I missing something more fundamental in the change from 0.18 to 0.19?

kyleobrien91 avatar Jun 14 '16 13:06 kyleobrien91

HI @kyleobrien91 and @Baachi I've created a pull request with this option included, can you please take a look: https://github.com/ddeboer/data-import/pull/311

IvBre avatar Sep 21 '16 09:09 IvBre