PHPackages                             madesimple/slim-validation - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Validation &amp; Sanitization](/categories/validation)
4. /
5. madesimple/slim-validation

ActiveLibrary[Validation &amp; Sanitization](/categories/validation)

madesimple/slim-validation
==========================

Abstract Slim middleware to allow request simple validation

v3.0.0(5y ago)41.0kMITPHPPHP &gt;=7.2CI failing

Since Aug 30Pushed 5y ago1 watchersCompare

[ Source](https://github.com/pdscopes/slim-validation)[ Packagist](https://packagist.org/packages/madesimple/slim-validation)[ RSS](/packages/madesimple-slim-validation/feed)WikiDiscussions master Synced today

READMEChangelog (3)Dependencies (6)Versions (6)Used By (0)

MadeSimple: slim-validation
===========================

[](#madesimple-slim-validation)

[![Build Status](https://camo.githubusercontent.com/9b18835dab83598e324d5eefe67ed665f3dfd6da4ebbf26ca9da87b813b8381b/68747470733a2f2f7472617669732d63692e6f72672f706473636f7065732f736c696d2d76616c69646174696f6e2e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/pdscopes/slim-validation)

Slim Validation is an abstract class to be extended to perform per route validation. Slim Validation allows two types of validation models:

- Validation as a function
- Validation as a middleware

Validation as a function is the recommended use case. Since Slim v4 has become more flexible there is no longer a straight forward method for extracting the request arguments as a middleware; this means that `getPathRules` checks are no longer supported by the validation as a middleware.

In both cases simply extend the abstract class `\MadeSimple\Slim\Middleware\Validation` and implement the three abstract methods:

1. `getPathRules` - allows you to validate the request path.
2. `getQueryParameterRules` - allows you to validate the query parameters of the request.
3. `getParsedBodyRules` - allows you to validate the parsed body of the request.

Slim Validation considers requests which violate the path rules as `404 Not Found`. Requests which violate either query parameter or parsed body rules should return as `422 Unprocessable Entity`.

For example:

```
