Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow customization of Validation group for Patch operations #11

Open
weierophinney opened this issue Dec 31, 2019 · 0 comments
Open

Allow customization of Validation group for Patch operations #11

weierophinney opened this issue Dec 31, 2019 · 0 comments

Comments

@weierophinney
Copy link
Contributor

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);
}

Originally posted by @Wilt at zfcampus/zf-content-negotiation#51

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

No branches or pull requests

1 participant