Skip to content

Exception when body is empty #13

@whites11

Description

@whites11

I am using this project to check the correctness of the query string parameters of a PUT call which is body-less by design.
I understand this is an edge case, but this is throwing an exception.

ZE\ContentValidation\Exception\UnexpectedValueException: Data Extractor `ZE\ContentValidation\Extractor\BodyExtractor` returned a `NULL` instead of an `array`
 in: /app/src/vendor/mvlabs/ze-content-validation/src/Extractor/DataExtractorChain.php: 54
#0 [internal function]: ZE\ContentValidation\Extractor\DataExtractorChain->ZE\ContentValidation\Extractor\{closure}(Object(ZE\ContentValidation\Extractor\BodyExtractor))
#1 /app/src/vendor/mvlabs/ze-content-validation/src/Extractor/DataExtractorChain.php(64): array_map(Object(Closure), Array)
#2 /app/src/vendor/mvlabs/ze-content-validation/src/Validator/ValidatorHandler.php(71): ZE\ContentValidation\Extractor\DataExtractorChain->getDataFromRequest(Object(Zend\Diactoros\ServerRequest))
#3 /app/src/vendor/mvlabs/ze-content-validation/src/Middleware/ValidationMiddleware.php(53): ZE\ContentValidation\Validator\ValidatorHandler->validate(Object(Zend\Diactoros\ServerRequest))
#4 /app/src/vendor/zendframework/zend-expressive/src/Middleware/LazyLoadingMiddleware.php(60): 

Maybe it would make sense to treath the "null" case as a special case returning an empty array in the BodyExtractor class

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions