PHPackages                             adaddinsane/paramverify - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. adaddinsane/paramverify

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

adaddinsane/paramverify
=======================

Parameter verification tool

1.4.2(8mo ago)0281↑2150%MITPHP

Since Aug 4Pushed 8mo ago1 watchersCompare

[ Source](https://github.com/adaddinsane/paramverify)[ Packagist](https://packagist.org/packages/adaddinsane/paramverify)[ RSS](/packages/adaddinsane-paramverify/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (2)Versions (14)Used By (0)

Parameter Verify
================

[](#parameter-verify)

A simple package to verify a set of array values, which are most likely parameters in a call. Sometimes you cannot specify in a list of arguments perhaps because it's too long, or because they might vary too much between derived class types.

This class is configured with an array which provides what values are required and their types. Non-required values can also be included to be checked - in which case they are only checked if they are present.

The main function returns an array of errors. If it's empty then everything was fine.

Structure
---------

[](#structure)

The settings array looks like this:

```
[
  'name' => [
    'required' => true,
    'type' => 'string',
    'data' => '',
    'range' => []
  ]
]
```

The 'name' is the key value in the array being tested (the name of the *property*).

Only the 'type' key is mandatory, and must be one of the acceptable values; the 'required' key is assumed false if missing; some types require an additional data string, for a 'regex' type it's the regular expression, for the 'class' type it's the fully qualified class name, and so on.

The 'range' key applies to string, int and float, and allows length and range restrictions to be inserted.

If a named parameter is in the settings array but not "required", no error is generated if it's missing, but it will be tested if it is present.

Types
-----

[](#types)

The complete list of types:

- **any** matches anything
- **null** matches only a null value (for completeness, you never know)
- **class** matches a specific class or interface (FQN in 'data')
- **object** matches any object
- **array** matches any array, arrays can contain their own definitions (see later).
- **int** matches an integer value (and can have a range)
- **bool** only matches true or false
- **int\_bool** matches true, false, 1 and 0
- **float** matches a float value (and can have a range)
- **string** matches any string (and can have a range)
- **string\_list** matches a string against a fixed list of strings (in 'data' separated by '|'). This is an old style "enum" which is also used to verify the types of the settings/configuration items.
- **regex** tests a string with a regular expression (in 'data')
- **callable** only matches a callable
- **resource** only matches a resource
- **url** matches a string which is also a valid URL
- **email** matches a string which is also a valid email address
- ***enum** only matches a PHP8.1 enum (FQN in 'data')*

How to use it
-------------

[](#how-to-use-it)

```
$settings = [
  'name' => [
    'required' => true,
    'type' => 'string'
  ],
  'value' => [
    'required' => true,
    'type' => 'int'
    'range' => [
      'min_value' => 1,
      'max_value' => 10
    ]
  ]
];

$paramVerifyFactory = new \ParamVerify\ParamVerifyFactory();

// This checks the settings and will throw an exception on error.
$verifier = $paramVerifyFactory->make($settings);

// Will return an error because 'name' is missing.
$parameters = ['value' => 5];
$errors = $verifier->verify($parameters);

// Will return no errors.
$parameters = ['name' => 'banana', 'value' => 5];
$errors = $verifier->verify($parameters);

// Will return an error because value is out of range.
$parameters = ['name' => 'banana', 'value' => 15];
$errors = $verifier->verify($parameters);

// Will return an error because name is not a string.
$parameters = ['name' => ['banana'], 'value' => 15];
$errors = $verifier->verify($parameters);
```

Array sub-properties
--------------------

[](#array-sub-properties)

Arrays can have an additional property called `settings` which defines a set of sub-properties for the array. There is no limit on the nesting - apart from resources and whether it's really a good idea.

```
$settings = [
  'name' => [
    'required' => true,
    'type' => 'string'
  ],
  'address' => [
    'required' => true,
    'type' => 'array'
    'settings' => [
      'line1' => ['required' => true, 'type' => 'string'],
      'line2' => ['type' => 'string'],
      'line3' => ['type' => 'string'],
      'postal_code' => ['required' => true, 'type' => 'string'],
    ]
  ]
];

$paramVerifyFactory = new \ParamVerify\ParamVerifyFactory();

// This checks the settings and will throw an exception on error.
$verifier = $paramVerifyFactory->make($settings);

// This would not generate any errors.
$parameters = [
  'name' => 'jane',
  'address' => [
    'line1' => 'first line of address',
    'line3' => 'third line of address',
    'postal_code' => 'XX1 73YY'
  ]
];
$errors = $verifier->verify($parameters);
```

###  Health Score

37

—

LowBetter than 83% of packages

Maintenance59

Moderate activity, may be stable

Popularity13

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity58

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~135 days

Recently: every ~364 days

Total

12

Last Release

264d ago

Major Versions

0.0.1 → 1.0.0-rc12021-08-05

PHP version history (3 changes)0.0.1PHP &gt;=7.4

1.0.0-rc1PHP &gt;=7.3

1.3.0PHP &gt;=7.2

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/291255?v=4)[Steve Turnbull](/maintainers/adaddinsane)[@adaddinsane](https://github.com/adaddinsane)

---

Top Contributors

[![adaddinsane](https://avatars.githubusercontent.com/u/291255?v=4)](https://github.com/adaddinsane "adaddinsane (23 commits)")

---

Tags

validationarrayparametervaluesverificationargument

### Embed Badge

![Health badge](/badges/adaddinsane-paramverify/health.svg)

```
[![Health](https://phpackages.com/badges/adaddinsane-paramverify/health.svg)](https://phpackages.com/packages/adaddinsane-paramverify)
```

###  Alternatives

[nette/utils

🛠 Nette Utils: lightweight utilities for string &amp; array manipulation, image handling, safe JSON encoding/decoding, validation, slug or strong password generating etc.

2.1k394.3M1.5k](/packages/nette-utils)[doctrine/collections

PHP Doctrine Collections library that adds additional functionality on top of PHP arrays.

6.0k411.1M1.2k](/packages/doctrine-collections)[symfony/property-access

Provides functions to read and write from/to an object or array using a simple string notation

2.8k295.3M2.5k](/packages/symfony-property-access)[league/config

Define configuration arrays with strict schemas and access values with dot notation

564302.2M24](/packages/league-config)[cuyz/valinor

Dependency free PHP library that helps to map any input into a strongly-typed structure.

1.5k9.2M108](/packages/cuyz-valinor)[lezhnev74/pasvl

Array Validator (regular expressions for nested array, sort of)

5253.7k3](/packages/lezhnev74-pasvl)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
