PHPackages                             lithemod/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. lithemod/validator

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

lithemod/validator
==================

A simple validator for validating input data in PHP applications.

v1.0.1(1y ago)12911MITPHP

Since Oct 2Pushed 1y agoCompare

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

READMEChangelogDependencies (2)Versions (3)Used By (1)

Lithe Validator
===============

[](#lithe-validator)

A simple validation class for PHP designed to validate various types of input data according to specified rules.

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

[](#installation)

You can install the Lithe Validator module via Composer. Run the following command in your project directory:

```
composer require lithemod/validator
```

Usage
-----

[](#usage)

### Step 1: Include Autoloader

[](#step-1-include-autoloader)

Make sure to include the Composer autoloader in your PHP script:

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

### Step 2: Initialize the Validator

[](#step-2-initialize-the-validator)

Create an instance of the `Validator` class by passing the data and the validation rules you want to apply.

```
use Lithe\Base\Validator;

$data = [
    'email' => 'example@example.com',
    'name' => 'John Doe',
    'age' => '25',
];

$rules = [
    'email' => 'required|email',
    'name' => 'required|name',
    'age' => 'required|integer|min:18|max:65',
];

$validator = new Validator($data, $rules);
```

### Step 3: Check Validation

[](#step-3-check-validation)

You can check if all validation rules pass using the `passed()` method:

```
if ($validator->passed()) {
    echo "Validation passed!";
} else {
    echo "Validation failed!";
    print_r($validator->errors());
}
```

### Supported Validation Rules

[](#supported-validation-rules)

- **`required`**: Checks if the field is present and not empty.
    **Error Code**: 1001
- **`email`**: Validates the format of an email address.
    **Error Code**: 1002
- **`url`**: Validates the format of a URL.
    **Error Code**: 1003
- **`ip`**: Validates the format of an IP address.
    **Error Code**: 1004
- **`number`**: Checks if the field is a numeric value.
    **Error Code**: 1005
- **`integer`**: Checks if the field is an integer.
    **Error Code**: 1006
- **`boolean`**: Validates if the field is a boolean value.
    **Error Code**: 1007
- **`min`**: Validates the minimum length of the field value.
    **Error Code**: 1009
- **`max`**: Validates the maximum length of the field value.
    **Error Code**: 1010
- **`range`**: Checks if the field value is within a specified range.
    **Error Code**: 1011
- **`dateFormat`**: Validates the date format.
    **Error Code**: 1012
- **`alphanumeric`**: Checks if the field value is alphanumeric.
    **Error Code**: 1013
- **`name`**: Validates that the field contains only letters and spaces.
    **Error Code**: 1014
- **`in`**: Checks if the field value is one of the allowed values.
    **Error Code**: 1015

Example
-------

[](#example)

```
$data = [
    'email' => 'user@example.com',
    'name' => 'Alice',
    'age' => '30',
];

$rules = [
    'email' => 'required|email',
    'name' => 'required|name',
    'age' => 'required|integer|min:18|max:65',
];

$validator = new Validator($data, $rules);

if ($validator->passed()) {
    echo "All validations passed!";
} else {
    echo "There were validation errors:";
    print_r($validator->errors());
}
```

License
-------

[](#license)

This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance39

Infrequent updates — may be unmaintained

Popularity14

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity40

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

Total

2

Last Release

528d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/56173de3a7bf7099dd8168efd730d3c2fb5df5174a123fdc37cee8c3589e2345?d=identicon)[williamhumbwavali](/maintainers/williamhumbwavali)

---

Top Contributors

[![williamhumbwavali](https://avatars.githubusercontent.com/u/127023095?v=4)](https://github.com/williamhumbwavali "williamhumbwavali (2 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  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)
