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

ActiveLibrary

bacarin/heimdall-validator
==========================

A pure PHP validation package inspired in Laravel way to validate data. Made in raw PHP without any dependency.

v0.0.1(8mo ago)01ISCPHP

Since Aug 13Pushed 8mo agoCompare

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

READMEChangelogDependenciesVersions (2)Used By (0)

HEIMDALL VALIDATOR
==================

[](#heimdall-validator)

Prevent unwanted data in your project with Heimdall Validator.

Heimdall Validator was inspired by Laravel and Symfony validators. It receives an associative array with data and another associative array with the desired validation rules.

This package does not throw exceptions or block any request. Instead, it returns a **Heimdall object** that lets you check validation results using `$validate->passes()` or `$validate->fails()`, and access detailed error messages with `$validate->errors()`. Examples are provided below.

Index
-----

[](#index)

- [Requirements](#requirements)
- [Installation](#installation)
- [How to Use](#how-to-use)
- [Available Methods](#available-methods)
- [Available Rules](#available-rules)

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

[](#requirements)

- PHP 7.0+ (not tested on older versions)
- No external dependencies. Built with pure PHP to avoid dependency issues and to be compatible with older PHP versions.

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

[](#installation)

You can install using Composer by running the command below:

**NOT AVAILABLE YET**

```
composer install bacarin/heimdall-validator
```

How to Use
----------

[](#how-to-use)

After installation, import the Bacarin\\Heimdall class and call the static validate method, passing the validation rules and the data to validate, like this:

```
use Bacarin\Heimdall;

function yourFunc(){
    $data = [
		'name' => 'John Doe',
		'age' => 18
	];
    $rules = [
		'name' => 'required|string|min:3',
		'age' => 'required|integer|max:80'
	];
    $validation = Heimdall::validate($rules, $data);
	if ($validation->passes()){
		... your code here
	}
}
```

Available Methods
-----------------

[](#available-methods)

### **`$validate->passes()`**

[](#validate-passes)

Returns a boolean indicating whether the payload is valid. Returns true if valid, false otherwise.

### **`$validate->fails()`**

[](#validate-fails)

Returns a boolean indicating whether the payload is invalid. Returns true if invalid, false otherwi

### **`$validate->errors()`**

[](#validate-errors)

Returns an associative array containing validation error messages. If empty, the payload is valid. Exampĺe:

```
[
	"access_level" => [
		"The field access_level is prohibited when role is in [admin, manager]."
	]
]
```

Available Rules
---------------

[](#available-rules)

More rules will be added in future releases or upon request.

RuleDescriptionParametersExample`accepted_if`Must be 'yes', 'on', '1', 1, true, or 'true' if another field has a specific valuefield,value`accepted_if:status,active``accepted`Must be 'yes', 'on', '1', 1, true, or 'true'`accepted``after_or_equal`Must be a date/datetime after or equal to a given date, or 'today', 'tomorrow', 'yesterday'date`after_or_equal:today`, `after_or_equal:2025-10-10``after`Must be a date/datetime after a given date, or 'today', 'tomorrow', 'yesterday'date`after:yesterday`, `after:2025-09-09``array`Must be an array`array``before_or_equal`Must be a date/datetime before or equal to a given date, or 'today', 'tomorrow', 'yesterday'date`before_or_equal:today`, `before_or_equal:2025-10-10``before`Must be a date/datetime before a given date, or 'today', 'tomorrow', 'yesterday'date`before:today`, `before:2025-10-10``boolean`Must be a boolean: true, false, 1, 0, 'true', or 'false'`boolean``date`Must be a valid date. Can also validate a specific format?format`date`, `date:Y-m-d``datetime`Must be a valid datetime. Can also validate a specific format?format`datetime`, `datetime:d/m/Y H:i``declined_if`Must be 'no', 'off', '0', 0, false, or 'false' if another field has a specific valuefield,value`declined_if:status,inactive``declined`Must be 'no', 'off', '0', 0, false, or 'false'`declined``email`Must be a valid email address`email``gte`Must be a number greater than or equal to a given valuevalue`gte:18``gt`Must be a number greater than a given valuevalue`gt:17``in`Must be one of the specified valuesvalue`in:paid,nonpaid,overdue,canceled``integer`Must be an integer`integer``lte`Must be a number less than or equal to a given valuevalue`lte:80``lt`Must be a number less than a given valuevalue`lt:81``max`Maximum value for numbers or maximum length for stringsvalue`max:100``min`Minimum value for numbers or minimum length for stringsvalue`min:3``nullable`Field can be null`nullable``prohibited_with`Field is prohibited if another field is presentfield`prohibited_with:company_name``prohibited_if`Field is prohibited if another field has a specific valuefield,value`prohibited_if:role,user``prohibited_if_in`Field is prohibited if another field has one of the specified valuesfield,value,value...`prohibited_if_in:role,admin,manager``regex`Must match the given regular expressionvalue`regex:^[a-z0-9]+$``required_if_in`Required if another field has one of the specified valuesfield,value,value...`required_if_in:status,active,pending``required_if`Required if another field has a specific valuefield,value`required_if:status,active``required_with`Required if another field is presentfield`required_with:name``required`Field is required`required``sometimes`Field is validated only if it is present`sometimes``string`Must be a string`string``uuid`Must be a valid UUID. Can specify the UUID version?value`uuid`, `uuid:4`-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

###  Health Score

23

—

LowBetter than 27% of packages

Maintenance58

Moderate activity, may be stable

Popularity1

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity25

Early-stage or recently created project

 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

Unknown

Total

1

Last Release

269d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/067c73fd83e6a9dd41e068c60030810e5905c078375886f72754adb4cc5caa70?d=identicon)[Bacarin](/maintainers/Bacarin)

---

Top Contributors

[![EduardoBacarin](https://avatars.githubusercontent.com/u/44368339?v=4)](https://github.com/EduardoBacarin "EduardoBacarin (1 commits)")

### Embed Badge

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

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

PHPackages © 2026

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