PHPackages                             hoppinger/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. hoppinger/validation

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

hoppinger/validation
====================

Several validator constraints for your Symfony2 (Validator) project

11391PHP

Since Dec 17Pushed 13y ago42 watchersCompare

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

READMEChangelogDependenciesVersions (1)Used By (0)

hoppinger/validation
====================

[](#hoppingervalidation)

Several validator constraints for your Symfony2 (Validator) project.

For now only a constraint `Compare` is available which allows you to compare two properties.

[![Build Status](https://camo.githubusercontent.com/fb5597d325f8c05a5b344e0710b621ce01a44d8234e2a1c36ce640751b91092f/68747470733a2f2f7472617669732d63692e6f72672f686f7070696e6765722f76616c69646174696f6e2e706e673f6272616e63683d6d6173746572)](https://travis-ci.org/hoppinger/validation)

Requirements
------------

[](#requirements)

For now only compatible with the Symfony 2.1+ validator.

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

[](#installation)

The recommended way to install this is with [Composer](http://getcomposer.org/). Just add `hoppinger/validation` to your composer.json by running:

```
$ php composer.phar require hoppinger/validation
```

Usage
-----

[](#usage)

You can use the constraints just like every other [Symfony constraint](http://symfony.com/doc/current/book/validation.html#constraints).

Constraints
-----------

[](#constraints)

### `Compare`

[](#compare)

The `Compare` constraint allows you to compare two properties of your object.

- Using annotations

```
// src/Acme/DemoBundle/Entity/Foo.php

/**
 * @Hop\Validation\Constraint\Compare(field="bar",compare_with="crux",operator="gt",message="Bar should be greater than crux")
 */
class Foo
{
	protected $bar;

	protected $crux;

	public function getBar()
	{
		return $this->bar;
	}

	public function getCrux()
	{
		return $this->crux;
	}

}
```

- Using YML

```
# src/Acme/DemoBundle/Resources/config/validation.yml
Acme\DemoBundle\Entity\Foo:
    constraints:
        - Hop\Validation\Constraint\Compare:
            field: bar
            compare_with: crux
            operator: gt
            message: Bar should be greater than crux

```

### Reference

[](#reference)

#### Options

[](#options)

The `Compare` constraint takes 4 arguments, of which all are required.

- `field`

The field name of your object which is compared.

- `compare_with`

The field name of your object with which `field` is compared with.

- `operator`

The operator to use. See below.

- `message`

The message that will be shown if the constraint doesn't validate.

#### Valid operators

[](#valid-operators)

- Compare::OP\_GT (`gt`)

Constraint matches if `field` is `greater than` `compare_with`

- Compare::OP\_GTE (`gte`)

Constraint matches if `field` is `greater than or equal to` `compare_with`

- Compare::OP\_LT (`lt`)

Constraint matches if `field` is `less than ` `compare_with`

- Compare::OP\_LTE (`lte`)

Constraint matches if `field` is `less than or equal to` `compare_with`

- Compare::OP\_EQ (`eq`)

Constraint matches if `field` is `equal to` `compare_with`

- Compare::OP\_NEQ (`neq`)

Constraint matches if `field` is `not equal to` `compare_with`

License
-------

[](#license)

hoppinger/validation is licensed under the MIT license.

###  Health Score

23

—

LowBetter than 26% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity13

Limited adoption so far

Community13

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/28606876af21640e6b63c08dd90b2f3c4de8ced80423279262d6923b18fcf493?d=identicon)[korstiaan](/maintainers/korstiaan)

---

Top Contributors

[![korstiaan](https://avatars.githubusercontent.com/u/902842?v=4)](https://github.com/korstiaan "korstiaan (19 commits)")

### Embed Badge

![Health badge](/badges/hoppinger-validation/health.svg)

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

PHPackages © 2026

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