PHPackages                             jardisport/validation - 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. jardisport/validation

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

jardisport/validation
=====================

Validator, value validator, and validation result interfaces for object and field-level validation

v1.0.0(2mo ago)0311proprietaryMakefilePHP &gt;=8.2CI passing

Since Mar 18Pushed 2mo agoCompare

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

READMEChangelog (1)Dependencies (6)Versions (6)Used By (1)

Jardis Validation Port
======================

[](#jardis-validation-port)

[![Build Status](https://github.com/jardisPort/validation/actions/workflows/ci.yml/badge.svg)](https://github.com/jardisPort/validation/actions/workflows/ci.yml/badge.svg)[![License: MIT](https://camo.githubusercontent.com/784362b26e4b3546254f1893e778ba64616e362bd6ac791991d2c9e880a3a64e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c6963656e73652d4d49542d677265656e2e737667)](LICENSE)[![PHP Version](https://camo.githubusercontent.com/a68b290dcc313d698dc138a1111aa83eee2f143605449d7e8b5416ea6f88558f/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d253345253344382e322d3737374242342e737667)](https://www.php.net/)[![PHPStan Level](https://camo.githubusercontent.com/c51bda247654363d3e30bc352674dd761a9557803a14af0226eb411d6dc0006b/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048505374616e2d4c6576656c253230382d627269676874677265656e2e737667)](phpstan.neon)[![PSR-12](https://camo.githubusercontent.com/34b10db0caa29bacd49bda5c437a8de95385f036f3230b31fa605326e18da22c/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f436f64652532305374796c652d5053522d2d31322d626c75652e737667)](phpcs.xml)

> Part of the **[Jardis Business Platform](https://jardis.io)** — Enterprise-grade PHP components for Domain-Driven Design

Validation contracts for object and field-level input verification. Three interfaces covering full object validation, individual value validation, and structured validation results with field-level error access. Swap validation libraries without changing a single line of domain code.

---

Interfaces
----------

[](#interfaces)

### **ValidatorInterface**

[](#validatorinterface)

`JardisPort\Validation\ValidatorInterface`

Generic contract for validating any PHP object. The validator receives the full object and returns a structured result.

MethodSignatureDescription`validate``validate(object $data): ValidationResult`Validates the given object and returns an immutable result.### **ValueValidatorInterface**

[](#valuevalidatorinterface)

`JardisPort\Validation\ValueValidatorInterface`

Stateless contract for validating individual values. Reusable across different fields with runtime options.

MethodSignatureDescription`validateValue``validateValue(mixed $value, array $options = []): ?string`Validates a single value. Returns an error message string on failure, `null` on success.### **ValidationResult**

[](#validationresult)

`JardisPort\Validation\ValidationResult`

Immutable value object holding a hierarchical error structure. Returned by `ValidatorInterface::validate()`.

MethodSignatureDescription`isValid``isValid(): bool`Returns `true` when no errors were recorded.`getErrors``getErrors(): array`Returns the full hierarchical error array.`hasErrorsForField``hasErrorsForField(string $field): bool`Check whether a specific field has any errors.`getErrorsForField``getErrorsForField(string $field): array`Get all errors for a specific field.`getFieldErrors``getFieldErrors(string $field): array`Get all errors for a specific field (alias for `getErrorsForField`).`hasFieldError``hasFieldError(string $field): bool`Returns `true` when a specific field has at least one error.`getFirstError``getFirstError(string $field): ?string`Get the first error message for a field, or `null`.`getAllFieldsWithErrors``getAllFieldsWithErrors(): array`Returns an array of all field names that have errors.`getErrorCount``getErrorCount(): int`Returns the number of fields with errors.---

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

[](#installation)

```
composer require jardisport/validation
```

Usage
-----

[](#usage)

```
use JardisPort\Validation\ValidatorInterface;
use JardisPort\Validation\ValueValidatorInterface;
use JardisPort\Validation\ValidationResult;

// Type-hint against ValidatorInterface for object-level validation
class RegistrationHandler
{
    public function __construct(
        private readonly ValidatorInterface $validator,
    ) {}

    public function handle(object $command): void
    {
        $result = $this->validator->validate($command);

        if (!$result->isValid()) {
            // Access field-level errors
            $emailErrors = $result->getErrorsForField('email');
            $firstError = $result->getFirstError('password');
            throw new \InvalidArgumentException('Validation failed');
        }

        // Proceed with the command
    }
}

// Type-hint against ValueValidatorInterface for reusable single-value checks
class EmailField
{
    public function __construct(
        private readonly ValueValidatorInterface $emailValidator,
    ) {}

    public function validate(string $email): ?string
    {
        return $this->emailValidator->validateValue($email);
    }
}
```

Implemented by
--------------

[](#implemented-by)

- **[jardissupport/validation](https://github.com/jardisSupport/validation)** — Attribute-driven object validation and composable value validators with support for nested structures

Documentation
-------------

[](#documentation)

Full documentation, guides, and API reference:

**[jardis.io/docs/port/validation](https://jardis.io/docs/port/validation)**

License
-------

[](#license)

This package is licensed under the [MIT License](LICENSE).

---

**[Jardis](https://jardis.io)** · [Documentation](https://jardis.io/docs) · [Headgent](https://headgent.com)

###  Health Score

41

—

FairBetter than 89% of packages

Maintenance88

Actively maintained with recent releases

Popularity10

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity50

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

Total

2

Last Release

62d ago

### Community

Maintainers

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

---

Top Contributors

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

---

Tags

interfacesvalidationdddHeadgentJardisPort

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP\_CodeSniffer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/jardisport-validation/health.svg)

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

###  Alternatives

[composer/semver

Version comparison library that offers utilities, version constraint parsing and validation.

3.3k489.6M672](/packages/composer-semver)[giggsey/libphonenumber-for-php

A library for parsing, formatting, storing and validating international phone numbers, a PHP Port of Google's libphonenumber.

5.0k148.7M416](/packages/giggsey-libphonenumber-for-php)[respect/validation

The most awesome validation engine ever created for PHP

5.9k37.4M383](/packages/respect-validation)[propaganistas/laravel-phone

Adds phone number functionality to Laravel based on Google's libphonenumber API.

3.0k35.7M107](/packages/propaganistas-laravel-phone)[opis/json-schema

Json Schema Validator for PHP

64736.9M186](/packages/opis-json-schema)[giggsey/libphonenumber-for-php-lite

A lite version of giggsey/libphonenumber-for-php, which is a PHP Port of Google's libphonenumber

8912.9M47](/packages/giggsey-libphonenumber-for-php-lite)

PHPackages © 2026

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