1. Go to this page and download the library: Download badelal2007/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/ */
badelal2007 / validator example snippets
$validator = new validator\Validator();
$validator->validate($_POST, [
'username' => 'word'
]);
#Return true if validation pass
var_dump($validator->passed());
#Return true if validation failed
var_dump($validator->failed());
#Return all errores if any
var_dump($validator->getErrors());
#Print first error if any for 'password' field
if($errors->get('password')) { echo '<span class="error">'.$errors->get('password')->first().'</span>'; }
#Print last error if any for 'password' field
if($errors->get('password')) { echo '<span class="error">'.$errors->get('password')->last().'</span>'; }
#Change 'message' for validation rule
$validator->validate($_POST, [
'email' => '