Allow customization of Validation group for Patch operations
Wilt opened this issue · 1 comments
This should be considered an improvement/feature request.
In the application I am working on we have resources where more then one field is required in the PATCH
operation. In the current implementation the content negotiation module matches the validation group with exactly the fields that are passed in the request.
This happens in the validatePatch
method in the ContentValidationListener
$inputFilter->setValidationGroup($validationGroup);
This is totally okay as a default behavior, but it would be great if we have some way of customizing the validation group for certain special cases by setting a validationGroup for PATCH
operations.
Not sure how to do this.
Right now I made an InputFilter
class where I redefined the setValidationGroup
method to prevent the ContentValidationListener
of setting the group like this:
/**
* Don't allow ContentValidationListener::validatePatch to set validation group
*
* @param mixed $group
* @return \Zend\InputFilter\InputFilterInterface
*/
public function setValidationGroup($group)
{
$group = self::VALIDATE_ALL;
return parent::setValidationGroup($group);
}
This repository has been closed and moved to laminas-api-tools/api-tools-content-negotiation; a new issue has been opened at laminas-api-tools/api-tools-content-negotiation#11.