PHP code example of knyga / evalidator
1. Go to this page and download the library: Download knyga/evalidator 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/ */
knyga / evalidator example snippets
$m = new EValidator([
['email', 'email']
]);
// $m->setData([
// 'email' => 'something'
// ]);
$object = new \StdClass;
$object->email = 'something';
$m->setData($object);
/**
* false
*/
var_dump($m->validate());
/**
* array(1) {
* ["email"]=>
* array(1) {
* [0]=>
* string(35) "Email is not a valid email address."
* }
* }
*/
var_dump($m->getErrors());
$m->setData([
'email' => '[email protected]'
]);
/**
* true
*/
var_dump($m->validate());