PHP code example of divineomega / omega-validator
1. Go to this page and download the library: Download divineomega/omega-validator library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
divineomega / omega-validator example snippets
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