Skip to content
This repository has been archived by the owner on Jan 21, 2020. It is now read-only.

Allow customization of Validation group for Patch operations #51

Open
Wilt opened this issue Aug 7, 2015 · 1 comment
Open

Allow customization of Validation group for Patch operations #51

Wilt opened this issue Aug 7, 2015 · 1 comment

Comments

@Wilt
Copy link
Contributor

Wilt commented Aug 7, 2015

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
Copy link
Member

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.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants