PHPackages                             topolis/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. [Validation &amp; Sanitization](/categories/validation)
4. /
5. topolis/validator

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

topolis/validator
=================

yaml based schema validation for multidimensional arrays

1.2.0(6y ago)0652MITPHPCI failing

Since Sep 7Pushed 6y agoCompare

[ Source](https://github.com/Topolis/Validator)[ Packagist](https://packagist.org/packages/topolis/validator)[ RSS](/packages/topolis-validator/feed)WikiDiscussions master Synced 5d ago

READMEChangelog (8)Dependencies (4)Versions (10)Used By (0)

Validator
=========

[](#validator)

A complex validator that applies a yaml based schema file to a multi dimensional array

Syntax
------

[](#syntax)

A schema is a hirarchical Yaml file. Each level, starting from the root of the file contains one of 3 different constructs.

### Properties

[](#properties)

Properties is an object with a list of named properties. Each property can then contain other constructs. The Yaml representation of an object construct is:

#### Options

[](#options)

- `type` defines if the property contains one sub construct or an array of sub constructs. Default: `single`
- `conditionals` a list of conditionals (need to contain a properties key if they are to replace the base object). Default: `undefined`
- `default` The default value if nothing is found. Default: `undefined` (will simply remove the property)
- `required` Defines if this property must be present. Default: `false`
- `filter` If type is `multiple`, this filter will be usedto validate the array keys. Default: `undefined`
- `options` If type is `multiple`, these are the options for the key filter. Default: `[]`
- `properties` The array of properties of this object. Default: `[]`
- `errors` individual status codes can be overriden with custom codes and messages for this one validation rule. Default: `[]` (See below=

#### Sample

[](#sample)

```
properties:
    one:
        ...
    two:
        ...
    three:
        ...
required: true
default: {one: A}

```

### Listing

[](#listing)

This defines a key value array. The difference to an object is that keys are not strictly defined but only need to pass a filter.

#### Options

[](#options-1)

- `conditionals` a list of conditionals (need to contain a properties key if they are to replace the base object). Default: `undefined`
- `default` The default value if nothing is found. Default: `undefined` (will simply remove the property)
- `required` Defines if this property must be present. Default: `false`
- `min` The required minimum number of array elements. Default: `false`
- `max` The required maximum number of array elements. Default: `false`
- `key` Needs to contain a Value construct with the filter to use for array keys. Default: `undefined`
- `value` Needs to contain a construct for array items. Default: `undefined`

#### Sample

[](#sample-1)

```
listing:
    required: true
    min: 2
    max: 10
    key:
        ...
    value:
        ...

```

### Value

[](#value)

This defines a singular value.

#### Options

[](#options-2)

- `filter` The filter to use (@see Topolis/Filter). Default: `Passthrough`
- `options` The options for this filter. Default: `[]` (Keep in mind that Validator sets the default type of filters to `single`)
- `strict` Defines if a value is allowed to be sanitized if possible or not. Default: `false`
- `default` The default value if nothing is found. Default: `undefined` (will simply remove the property)
- `required` Defines if this property must be present. Default: `false`

#### Sample

[](#sample-2)

```
filter: PlainExt
options: {characters: ".-_"}
required: true
default: Pustekuchen

```

Custom Errors
-------------

[](#custom-errors)

FOr each validation rule, a custom error can bespecified for individual status codes. Be carefull with custom codes though as there are certain rules expected from your validation results.

- `Positive/Negative` following typical process exit codes, any positive code is considered a success. Any negative code is considered a failure
- `Severity` The more negative a number is, the more dramatic is the error. Most calling programms expect correct values for invalid or sanitized results. Be carefull to not break your result code checks.

### Default error codes

[](#default-error-codes)

- `ERROR = -100` A critical execution or configuration error
- `INVALID = -11` The result did not pass the minimal required rules
- `SANITIZED = -2` The result has non-critical problems. The values causeing these problems could be adjusted automatically
- `INFO = -1` The result is completely valid but there are informational messages
- `VALID = 1` The result is completely valid

#### Sample

[](#sample-3)

```
filter: PlainExt
options: {characters: ".-_"}
errors:
    -2:
        code: -1
        message: This data could be sanitized but we think a info alone is enough
    -11:
        code: -192
        message: This very special check failed

```

Open Tasks
----------

[](#open-tasks)

- BUG: Definition wrong in StatusManager (Can't reproduce. Where?)
- FR: reference definitions in other files
- FR: Auto incremental indexes in listings

###  Health Score

31

—

LowBetter than 68% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity13

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity69

Established project with proven stability

 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 ~108 days

Recently: every ~159 days

Total

8

Last Release

2413d ago

Major Versions

0.1.1 → 1.0.02018-01-05

### Community

Maintainers

![](https://www.gravatar.com/avatar/f3e51460b8424774241a747201a81cdc8a8d9734007b3ef4fd7b997f8a4271ab?d=identicon)[ToBe998](/maintainers/ToBe998)

---

Top Contributors

[![ToBe998](https://avatars.githubusercontent.com/u/12497310?v=4)](https://github.com/ToBe998 "ToBe998 (36 commits)")

---

Tags

schemavalidationsecuritylibraryyamltopolis

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/topolis-validator/health.svg)

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

###  Alternatives

[romaricdrigon/metayaml

Using \[Yaml|Xml|json\] schemas files to validate \[Yaml|Xml|json\]

103306.5k8](/packages/romaricdrigon-metayaml)[karser/karser-recaptcha3-bundle

Google ReCAPTCHA v3 for Symfony

1862.4M7](/packages/karser-karser-recaptcha3-bundle)[siriusphp/validation

Data validation library. Validate arrays, array objects, domain models etc using a simple API. Easily add your own validators on top of the already dozens built-in validation rules

181743.3k13](/packages/siriusphp-validation)[olssonm/l5-zxcvbn

Implementation of the zxcvbn project by @dropbox for Laravel. Uses zxcvbn-php by @bjeavons.

28311.1k1](/packages/olssonm-l5-zxcvbn)[evaisse/php-json-schema-generator

A JSON Schema Generator.

20298.5k1](/packages/evaisse-php-json-schema-generator)[progsmile/request-validator

Simple PHP Request Validator

33113.3k1](/packages/progsmile-request-validator)

PHPackages © 2026

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