PHPackages                             hgg/parameter-validator - 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. [HTTP &amp; Networking](/categories/http)
4. /
5. hgg/parameter-validator

ActiveLibrary[HTTP &amp; Networking](/categories/http)

hgg/parameter-validator
=======================

Framework for specifying and enforcing rules on key/value pairs

v0.1.4(10y ago)5103.8k—4.2%23MITPHPPHP &gt;=5.3.3

Since Oct 16Pushed 10y ago1 watchersCompare

[ Source](https://github.com/hglattergotz/parameter-validator)[ Packagist](https://packagist.org/packages/hgg/parameter-validator)[ Docs](http://github.com/hglattergotz/parameter-validator)[ RSS](/packages/hgg-parameter-validator/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (2)Dependencies (1)Versions (7)Used By (3)

Framework for specifying and enforcing rules on key/value pairs

[![Build Status](https://camo.githubusercontent.com/3b330ccfca3c34d1e8ebaea618e490e6cfdaec4b30efc2b3450ab966e8deec1e/68747470733a2f2f7472617669732d63692e6f72672f68676c6174746572676f747a2f706172616d657465722d76616c696461746f722e737667)](https://travis-ci.org/hglattergotz/parameter-validator)[![Latest Stable Version](https://camo.githubusercontent.com/19f5152d3727c9e1b13f8f61641b03f742d977b69f236c946ce4c12e92ded143/68747470733a2f2f706f7365722e707567782e6f72672f6867672f706172616d657465722d76616c696461746f722f762f737461626c652e737667)](https://packagist.org/packages/hgg/parameter-validator)[![Total Downloads](https://camo.githubusercontent.com/5ab3160b9f2b6ef8aaa55d56dad47d38ba3081ab1a866572e5d1fc821a40b917/68747470733a2f2f706f7365722e707567782e6f72672f6867672f706172616d657465722d76616c696461746f722f646f776e6c6f6164732e737667)](https://packagist.org/packages/hgg/parameter-validator)[![License](https://camo.githubusercontent.com/e0bdf7a5167f8d9d3558e7a1531e52ed1ba2a919a31485e788a592e401858a9d/68747470733a2f2f706f7365722e707567782e6f72672f6867672f706172616d657465722d76616c696461746f722f6c6963656e73652e737667)](https://packagist.org/packages/hgg/parameter-validator)

Installation
------------

[](#installation)

Using Composer:

```
{
    "require": {
        "hgg/parameter-validator": "dev-master"
    }
}
```

Use Cases
---------

[](#use-cases)

### Url Query String Parameters

[](#url-query-string-parameters)

A framework like Symfony 2 provides the Request object from which one can obtain the query string parameters either one by one

```
$param = $request->query->get('name-of-parameter');
```

or all at once

```
$params = $request->query->all();
```

This is really convenient but the validation of these parameters is still left to the developer and becomes really tedious. You still have to ensure that all required parameters are present and that the values for them are of the correct type, etc.

This framework allows the definition of rules for the parameters and can even validate the values for these parameters.

Example - Url Query String Parameter Validation in Symfony 2
------------------------------------------------------------

[](#example---url-query-string-parameter-validation-in-symfony-2)

SomeApiMethod.php

```
