PHPackages                             jatnnik/brainiac - 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. jatnnik/brainiac

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

jatnnik/brainiac
================

A schema validation library for PHP, heavily inspired by Zod.

v2.0.1(1y ago)07MITPHP

Since May 18Pushed 1y ago1 watchersCompare

[ Source](https://github.com/jatnnik/brainiac)[ Packagist](https://packagist.org/packages/jatnnik/brainiac)[ RSS](/packages/jatnnik-brainiac/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (3)Dependencies (3)Versions (8)Used By (0)

🧠 brainiac
==========

[](#-brainiac)

A PHP schema validation library, heavily inspired by [Zod](https://zod.dev).

Quality of Code
---------------

[](#quality-of-code)

Brainiacs code is fully tested and compliant with [PHPStan](https://phpstan.org) at max level.

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

[](#installation)

```
composer require jatnnik/brainiac
```

Usage
-----

[](#usage)

At the moment, the following data types are supported:

- [Arrays](#arrays)
- [Booleans](#booleans)
- [Numbers](#numbers)
- [Strings](#strings)

You may either use the `parse` or `safe_parse` method. `parse` will throw an exception when validation fails, while `safe_parse` will always return an associative array with the following shape, based on validation success:

```
// On validation success.
$success = [
  "success" => true,
  "data" => "parsed value",
];

// On validation failure.
$failure = [
  "success" => false,
  "error" => "error message",
];
```

### Arrays

[](#arrays)

```
