zfcampus / zf-content-negotiation

BSD 3-Clause "New" or "Revised" License
18 stars 32 forks source link

Allow customization of Validation group for Patch operations #51

Open Wilt opened 9 years ago

Wilt commented 9 years ago

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);
}
weierophinney commented 4 years ago

This repository has been closed and moved to laminas-api-tools/api-tools-content-negotiation; a new issue has been opened at https://github.com/laminas-api-tools/api-tools-content-negotiation/issues/11.