zfcampus / zf-content-validation

ZF2 module for automated input validation
BSD 3-Clause "New" or "Revised" License
20 stars 25 forks source link

Filters throw uncaught exceptions and return improper response code #32

Open ashireman opened 9 years ago

ashireman commented 9 years ago

When validating the supplied data it's possible for a Filter that is attached to the InputFilter to throw an Exception. If this happens, Apigility will return a status code of 200 and depending on your settings it may show the Exception message or stack trace.

I propose wrapping the

$inputFilter->isValid()

call on https://github.com/zfcampus/zf-content-validation/blob/master/src/ContentValidationListener.php#L216 in a try/catch block, and returning a ApiProblemResponse with a status code of 422 should an Exception be thrown.

weierophinney commented 4 years ago

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