PHPackages                             bugadani/validatiny - 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. bugadani/validatiny

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

bugadani/validatiny
===================

A simple object validator library

028[1 issues](https://github.com/bugadani/Validatiny/issues)PHP

Since May 6Pushed 10y ago1 watchersCompare

[ Source](https://github.com/bugadani/Validatiny)[ Packagist](https://packagist.org/packages/bugadani/validatiny)[ RSS](/packages/bugadani-validatiny/feed)WikiDiscussions master Synced yesterday

READMEChangelogDependenciesVersions (1)Used By (0)

[![Build Status](https://camo.githubusercontent.com/aab3980cd14683c2fef38bfafdbde16d166bdc1cf162aa6cf9aa584804ba6421/68747470733a2f2f7472617669732d63692e6f72672f6275676164616e692f56616c69646174696e792e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/bugadani/Validatiny)

Validatiny
==========

[](#validatiny)

Validatiny is a simple PHP library used to validate objects against a set of rules.

Validatiny is licensed under the MIT license.

Rules
=====

[](#rules)

Validatiny uses subclasses of Validatiny\\Rule to validate objects. The current subclasses are:

- All - validates against a list of Rules where all Rules must apply
- Boolean - accepts only true or false
- Callable - accepts callable values
- Callback - calls a function or static method to validate the value.
- CollectionOf - validates a collection of elements against a single rule (e.g. validates is something is an array of numbers)
- Enum - validates against a list of values
- Not - negates the result of the inner validator
- Number - validates a numeric value with optional range parameters
- Object - checks the object type and optionally validates the object as well
- Optional - accepts null or validates using an inner rule
- Pattern - validates a regexp pattern
- String - validates a string with optional length parameters
- Structure - validates that the given object or array has the given fields. This rule has a 'strict' option that requires the validated array or object to only have the specified fields.
- Union - validates against a list of Rules where at least one of the Rules must apply, useful for collections or optional rules
- more to come...

Validatiny can apply the Rules on public properties and getter methods. Any number of Rules may be set and all of them must be valid in order for the property and/or method to be considered valid. An object is considered valid if all of its properties and methods are valid.

The following Rules can also be applied to objects, as well:

- All
- Callback
- Not
- Optional
- Union

Note: generic validation rules can be applied as PHP code using the Callback Rule on the validated class.

Validation scenarios
====================

[](#validation-scenarios)

Rules can be added to specific validation scenarios. This enables the user to specify multiple sets of rules on a single object.

To specify which rule should belong to which scenario, use the `scenario: 'scenarioName'` attribute on the rule annotation, or call `$rule->setScenario()`. Both of these accept a single name or an array of scenario names.

By default, Validatiny validates all rules on an object. To override this behaviour, pass the name of the validation scenario as the second parameter for `Validator::validate`.

To be continued...

###  Health Score

20

—

LowBetter than 13% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity41

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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/2ba12833634c15d1916a7f3f29be4d1a89d40c36e7ebab46a576ff9b6e75caa6?d=identicon)[bugadani](/maintainers/bugadani)

---

Top Contributors

[![bugadani](https://avatars.githubusercontent.com/u/977627?v=4)](https://github.com/bugadani "bugadani (30 commits)")

### Embed Badge

![Health badge](/badges/bugadani-validatiny/health.svg)

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

###  Alternatives

[marcosh/php-validation-dsl

A DSL for validating data in a functional fashion

483.9k](/packages/marcosh-php-validation-dsl)

PHPackages © 2026

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