PHPackages                             tanoconsulting/datavalidatorbundle - 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. [Database &amp; ORM](/categories/database)
4. /
5. tanoconsulting/datavalidatorbundle

ActiveSymfony-bundle[Database &amp; ORM](/categories/database)

tanoconsulting/datavalidatorbundle
==================================

A tool to validate Data stored in Databases and Filesystems

1.0.0-BETA1(4y ago)02081GPL-2.0PHPPHP ^7.3|^8.0

Since Mar 1Pushed 4y ago1 watchersCompare

[ Source](https://github.com/tanoconsulting/datavalidatorbundle)[ Packagist](https://packagist.org/packages/tanoconsulting/datavalidatorbundle)[ GitHub Sponsors](https://github.com/sponsors/tanoconsulting)[ RSS](/packages/tanoconsulting-datavalidatorbundle/feed)WikiDiscussions main Synced today

READMEChangelog (2)Dependencies (8)Versions (4)Used By (1)

Data Validator Bundle
=====================

[](#data-validator-bundle)

Goals
-----

[](#goals)

Allow checking integrity of data in a database, going beyond what the database schema definition enforces.

Allow checking the integrity of a set of files (WIP).

Usecase
-------

[](#usecase)

There are many scenarios in which usage of the constraints configured in a database schema is not sufficient to enforce data integrity, such as f.e.:

- the db engine in use not supporting advanced/complex data validation constraints
- the db engine in use does support advanced data validation constraints, but those are not being used
- data integrity constraints which are too complex to express easily using the db engine
- db native constraints having been disabled for speed during mass import operations
- constraints having been implemented in application code, with multiple apps writing to the database

In all those cases, a separate tool which can validate that the data stored in the database adheres to a set of rules can come in handy.

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

[](#requirements)

- php 7.3 or later
- a database supported by Doctrine DBAL (2.11 or 3.0 or later)
- Symfony components: see `composer.json`

Quick start
-----------

[](#quick-start)

1. the set of constraints can be defined in a yaml or json file. This sample shows the supported syntax, using yaml:

    ```
    constraints:
      -
        ForeignKey:
          child:
            ezapprove_items: collaboration_id
          parent:
            ezcollab_item: id
      -
        ForeignKey:
          child:
            ezbinaryfile: [contentobject_attribute_id, version]
          parent:
            ezcontentobject_attribute: [id, version]
       -
        ForeignKey:
          child:
            ezcontentobject: id
          parent:
            ezcontentobject_version: contentobject_id
          except: 'ezcontentobject.status = 1 AND ezcontentobject_version.status = 1'
      -
        Query:
          name: classes_with_same_identifier
          sql: 'SELECT identifier, COUNT(*) AS identical_identifiers FROM ezcontentclass WHERE version = 0 GROUP BY identifier HAVING COUNT(*) > 1'
          # skip the validation of this constraint in a silent manner if the table is missing by using the line below:
          requires: {table: ezcontentclass}
    ```
2. run the validation command

    ```
     php bin/console datavalidator:validate:database --config-file=

    ```

    This presumes that your application has set up a database connection configuration doctrine named `default`. If that is not the case, you can run:

    ```
     php bin/console datavalidator:validate:database --config-file= --database=

    ```

    If you want to list the validations constraints without validating them run:

    ```
     php bin/console datavalidator:validate:database --config-file= --dry-run

    ```

    By default the results show the number of database rows found which violate each constraint. To see the data of those rows instead, use:

    ```
     php bin/console datavalidator:validate:database --config-file= --display-data

    ```

Constraints currently supported
-------------------------------

[](#constraints-currently-supported)

- foreign key definitions
- custom sql queries

See the doc/samples folder for examples constraints of well-known applications' database schemas.

More advanced usage
-------------------

[](#more-advanced-usage)

### Defining validation constraints in your code

[](#defining-validation-constraints-in-your-code)

Instead of using a dedicated configuration file on the command line, you can configure the validation constraints in code, either:

- by setting a value to configuration parameter `data_validator.constraints.database`, or
- by tagging services with the `data_validator.constraint_provider.database` tag. Those services will have to implement a public method `getConstraintDefinitions()` that returns all the relevant constraints definitions

### Creating your own constraint types

[](#creating-your-own-constraint-types)

WIP

Troubleshooting
---------------

[](#troubleshooting)

- Use the `-v` command line option to see details of execution
- If the execution of the constraint validation is taking a long time, you can use CTRL-C to stop execution halfway: the script will exit gracefully printing any violation found up to that point
- To avoid excessive memory usage from large queries, when running Symfony in "debug mode", such as commonly for "dev" envs, add the `--no-debug` option to your commands. If possible, use a non-debug Symfony env.
- If you still get an 'allowed memory size' fatal error, run the commands with `php -d memory_limit=-1`.

FAQ
---

[](#faq)

- Q: can I run the validations in a Controller or Event instead of a cli command? A: technically yes, but it is generally not recommended, as the database queries used for validating the whole data set might take long to execute

Thanks
------

[](#thanks)

Code based on the Symfony/Validator component; thanks to all its developers!

[![License](https://camo.githubusercontent.com/20d98dd2335948b371d4ad34fd841e07a8bf8c8d072784b060825a6f9bfe7168/68747470733a2f2f706f7365722e707567782e6f72672f74616e6f636f6e73756c74696e672f6461746176616c696461746f7262756e646c652f6c6963656e7365)](https://packagist.org/packages/tanoconsulting/datavalidatorbundle)[![Latest Stable Version](https://camo.githubusercontent.com/545c8de08a098f99220a2b66f96d0d63609d9e67663feadb28d5e6d0338cdd38/68747470733a2f2f706f7365722e707567782e6f72672f74616e6f636f6e73756c74696e672f6461746176616c696461746f7262756e646c652f762f737461626c65)](https://packagist.org/packages/tanoconsulting/datavalidatorbundle)[![Total Downloads](https://camo.githubusercontent.com/c06ceb0cfac38a9a697526a4029edf598dee3d43071b52f03c89580d2744c49c/68747470733a2f2f706f7365722e707567782e6f72672f74616e6f636f6e73756c74696e672f6461746176616c696461746f7262756e646c652f646f776e6c6f616473)](https://packagist.org/packages/tanoconsulting/datavalidatorbundle)

###  Health Score

23

—

LowBetter than 30% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity11

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity45

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

Total

3

Last Release

1783d ago

### Community

Maintainers

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

---

Top Contributors

[![gggeek](https://avatars.githubusercontent.com/u/308634?v=4)](https://github.com/gggeek "gggeek (34 commits)")

---

Tags

database-schemaintegrity-constraintssymfonyvalidationdatabaseconstraintcompliance

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/tanoconsulting-datavalidatorbundle/health.svg)

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

###  Alternatives

[doctrine/doctrine-bundle

Symfony DoctrineBundle

4.8k237.2M3.0k](/packages/doctrine-doctrine-bundle)[edyan/neuralyzer

Library and CLI for Data anonymization

53146.8k2](/packages/edyan-neuralyzer)[smile/gdpr-dump

A utility to create anonymized database dumps

21531.3k](/packages/smile-gdpr-dump)[backup-manager/symfony

A simple database backup manager for Symfony2 with support for S3, Rackspace, Dropbox, FTP, SFTP.

124291.7k3](/packages/backup-manager-symfony)[bartlett/php-compatinfo-db

Reference Database of all functions, constants, classes, interfaces on PHP standard distribution and about 110 extensions

1182.8k1](/packages/bartlett-php-compatinfo-db)[webnet-fr/database-anonymizer

Database anonymizer.

3632.8k2](/packages/webnet-fr-database-anonymizer)

PHPackages © 2026

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