PHPackages                             denis/validate - 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. denis/validate

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

denis/validate
==============

Data validation library for MobileXCo

08PHP

Since Nov 28Pushed 11y ago1 watchersCompare

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

READMEChangelogDependenciesVersions (1)Used By (0)

Validate
========

[](#validate)

A sample data validation library. The goal was to create a data validation library as a composer module. This was a test requested by Mobile X Co.

Installing
----------

[](#installing)

This library can be installed with composer. To get composer:

```
curl -sS https://getcomposer.org/installer | php

```

Add this to your composer.json file.

```
{
    "require" : {
        "denis/validate": "dev-master"
    }
}

```

Then run composer install.

```
php composer.phar install

```

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

[](#how-to-use)

The schema is supplied in json format to the parse method. The isValid method is then called which returns a json response. The response will indicate if the data string is valid compared to the schema provided. If there are errors they will be in the response.

```
require_once 'vendor/autoload.php';

use MobileXCo\Validate;

$validate = new Validate();

$validate->parse($schema);

$result = $validate->isValid($data);

```

Data types supported
--------------------

[](#data-types-supported)

- string (A string)
- int (An integer)
- email (Must be a string. Example "")
- date (Must be a string. Example "2014-09-13")

Extra constraints
-----------------

[](#extra-constraints)

Elements can be marked as required by adding the required parameter. Type string and int can have a min and max length.

Testing
-------

[](#testing)

Testing with PHPUnit can be found under test folder.

Schema Example
--------------

[](#schema-example)

```
{
    "id": {
        "type": "int",
        "required": true
    },
    "name": {
        "type": "string",
        "min": 5,
        "max": 30,
        "required": true
    },
    "description": {
        "type": "string",
        "max": 50
    },
    "price": {
        "type": "int",
        "min": 1
    },
    "orderOn": {
        "type": "date"
    },
    "address": {
        "type":"email"
    }
}

```

Data Examples
-------------

[](#data-examples)

```
{
    "id": 25,
    "description": "Blue car."
}

```

isValid -&gt; false, error: \[name is required\]

```
{
    "id": 21,
    "name": "Red car"
}

```

isValid -&gt; true, error: \[\]

###  Health Score

20

—

LowBetter than 14% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity4

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/6c567b1f25ce886340cc9effee947a5547e1149aa5fa4c164b267230d0362120?d=identicon)[d3berger](/maintainers/d3berger)

---

Top Contributors

[![d3berger](https://avatars.githubusercontent.com/u/6660296?v=4)](https://github.com/d3berger "d3berger (6 commits)")

### Embed Badge

![Health badge](/badges/denis-validate/health.svg)

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

###  Alternatives

[webmozart/assert

Assertions to validate method input/output with nice error messages.

7.6k894.0M1.2k](/packages/webmozart-assert)[bensampo/laravel-enum

Simple, extensible and powerful enumeration implementation for Laravel.

2.0k15.9M104](/packages/bensampo-laravel-enum)[swaggest/json-schema

High definition PHP structures with JSON-schema based validation

48612.5M73](/packages/swaggest-json-schema)[stevebauman/purify

An HTML Purifier / Sanitizer for Laravel

5325.6M19](/packages/stevebauman-purify)[ashallendesign/laravel-config-validator

A package for validating your Laravel app's config.

217905.3k5](/packages/ashallendesign-laravel-config-validator)[crazybooot/base64-validation

Laravel validators for base64 encoded files

1341.9M8](/packages/crazybooot-base64-validation)

PHPackages © 2026

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