horat1us / yii2-uuid-validator
Yii2 UUID Validator
Installs: 1 500
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 0
Open Issues: 0
Requires
- php: >=7.2
- ramsey/uuid: ^3.8
- yiisoft/yii2: ^2.0.15
Requires (Dev)
- phpunit/phpunit: ^8.0
- squizlabs/php_codesniffer: ^3.4
This package is auto-updated.
Last update: 2024-10-19 16:59:33 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], ]; } }