PHPackages                             vigihdev/yii2-bridge-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. vigihdev/yii2-bridge-validator

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

vigihdev/yii2-bridge-validator
==============================

Custom validation rules and enhanced validator for Yii2 with database-aware validators and i18n support

014PHPCI passing

Since Nov 1Pushed 6mo agoCompare

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

READMEChangelogDependenciesVersions (1)Used By (0)

Yii2 Bridge Validator
=====================

[](#yii2-bridge-validator)

[![PHP Version](https://camo.githubusercontent.com/cc9cdea9aa96b40a822425e981b0a030e3371202973c7d57b74e8e99834f81dc/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d253545382e312d626c7565)](https://www.php.net/)[![License](https://camo.githubusercontent.com/f8df3091bbe1149f398a5369b2c39e896766f9f6efba3477c63e9b4aa940ef14/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d677265656e)](LICENSE)[![Tests](https://camo.githubusercontent.com/d940ad7f0752e2cbe0d63c50dcebf329078807390051c41fe63258f1b5c4e182/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f74657374732d70617373696e672d627269676874677265656e)](tests/)

Custom validation rules and enhanced validator for Yii2 with database-aware validators and i18n support.

Features
--------

[](#features)

- 🔍 Database-aware validation rules (ExistsRecord, UniqueRecord)
- 🌐 Multilingual validation messages with i18n support
- 🏗️ Service container integration
- 📝 Enhanced validation with custom rules
- ⚡ High performance with caching support
- 🧪 Comprehensive test coverage

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

[](#installation)

```
composer require vigihdev/yii2-bridge-validator
```

Quick Start
-----------

[](#quick-start)

### Basic Usage

[](#basic-usage)

```
use VigihDev\Yii2Bridge\Validator\Rules\{ExistsRecordRule, UniqueRecordRule};
use Yiisoft\Validator\Rule\{Required, Length, Email};

class User extends BaseActiveRecord
{
    #[Required]
    #[Length(min: 3, max: 255)]
    #[UniqueRecordRule(targetClass: User::class, targetAttribute: 'username')]
    public string $username = '';

    #[Required]
    #[Email]
    public string $email = '';
}
```

### Database Validation Rules

[](#database-validation-rules)

```
// Check if record exists
#[ExistsRecordRule(
    targetClass: User::class,
    targetAttribute: 'id',
    message: 'User not found'
)]
public int $user_id;

// Ensure uniqueness
#[UniqueRecordRule(
    targetClass: User::class,
    targetAttribute: 'email',
    message: 'Email already exists'
)]
public string $email;
```

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

[](#available-rules)

- **ExistsRecordRule** - Validates that a record exists in database
- **UniqueRecordRule** - Ensures field value is unique in database

Testing
-------

[](#testing)

Run the test suite:

```
composer test
```

Run development server:

```
composer run server
```

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

[](#requirements)

- PHP 8.1 or higher
- Yiisoft Validator ^2.5
- Yiisoft Cache ^3.1

License
-------

[](#license)

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

Author
------

[](#author)

**Vigih Dev**

- Email:
- GitHub: [@vigihdev](https://github.com/vigihdev)

Contributing
------------

[](#contributing)

Contributions are welcome! Please feel free to submit a Pull Request.

###  Health Score

18

—

LowBetter than 8% of packages

Maintenance47

Moderate activity, may be stable

Popularity6

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity13

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.

### Community

Maintainers

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

---

Top Contributors

[![vigihdev](https://avatars.githubusercontent.com/u/95208065?v=4)](https://github.com/vigihdev "vigihdev (3 commits)")

### Embed Badge

![Health badge](/badges/vigihdev-yii2-bridge-validator/health.svg)

```
[![Health](https://phpackages.com/badges/vigihdev-yii2-bridge-validator/health.svg)](https://phpackages.com/packages/vigihdev-yii2-bridge-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)[nette/forms

📝 Nette Forms: generating, validating and processing secure forms in PHP. Handy API, fully customizable, server &amp; client side validation and mature design.

54013.2M450](/packages/nette-forms)[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)

PHPackages © 2026

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