divineomega / omega-validator
Omega Validator
Fund package maintenance!
DivineOmega
Installs: 20 088
Dependents: 1
Suggesters: 0
Security: 0
Stars: 2
Watchers: 3
Forks: 0
Open Issues: 1
Requires
- php: >=7.1
- ext-json: *
- ext-pdo: *
- divineomega/translator: ^1.0.1
This package is auto-updated.
Last update: 2024-10-27 21:16:12 UTC
README
Installation
To install Omega Validator, just run the following Composer command.
composer require divineomega/omega-validator
Usage
See the following example usage.
use DivineOmega\OmegaValidator\Rules\IsEmail; use DivineOmega\OmegaValidator\Rules\IsString; use DivineOmega\OmegaValidator\Rules\Required; use DivineOmega\OmegaValidator\Translator; use DivineOmega\OmegaValidator\Validator; /* ... */ $validator = new Validator([ 'email' => '', ], [ 'email' => [ new Required(), new IsEmail(), new IsString(), ], ]); if ($validator->fails()) { // English messages var_dump($validator->messages()); // array(1) { // ["email"]=> // array(2) { // ["DivineOmega\OmegaValidator\Rules\Required"]=> // string(22) "The email is required." // ["DivineOmega\OmegaValidator\Rules\IsEmail"]=> // string(40) "The email must be a valid email address." // } // } // German messages var_dump($validator->messages(new Translator('de'))); // Polish messages var_dump($validator->messages(new Translator('pl'))); // etc... }