horat1us / yii2-uuid-validator
Yii2 UUID Validator
Installs: 1 542
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 0
Open Issues: 0
Requires
- php: ^7.4 | ^8
- ramsey/uuid: ^3.8 | ^4.7
- yiisoft/yii2: ^2.0.51
Requires (Dev)
- horat1us/yii2-asset-free: ^1.0
- phpunit/phpunit: ^9.5
- squizlabs/php_codesniffer: ^3.10.3
This package is auto-updated.
Last update: 2024-12-11 15:08:20 UTC
README
Simple validator that uses ramsey/uuid to validate UUID in models etc.
Main purpose of this validator - use it instead of regular expression validator to prevent mistakes.
Installation
Using packagist.org:
composer require horat1us/yii2-uuid-validator:^1.0
Usage
Just add it to rules of our \yii\base\Model
:
<?php namespace App; use Horat1us\Yii\UuidValidator; use yii\base; class Model extends base\Model { /** @var string attribute to be validated */ public $uuid; public function rules() { return [ [['uuid',], 'required',], [['uuid',], UuidValidator::class], ]; } }