1. Go to this page and download the library: Download lmcmi/validators 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/ */
lmcmi / validators example snippets
dator = new \Validators\Validator;
$result = $validator->string()->maxLength(10)->t error message
}
$values = [
'field_1' => [
"a" => "string",
"b" => "should_be_int",
"c" => []
],
"field_2" => '{"json": "valid"}'
];
$rules = [
"field_1" => "array|alidade($values);
$result->failedOnField("teste.c"); // Returns false
$result->failed(); // Returns true
$result->throwOnFirstError(); // Throws an exception with the first error message
$result->failedOnRule('string'); // Returns true
$result->getErrorsMessages(); // Returns all error messages if they exist
namespace My\Namespace;
class Required implements \Validators\Contracts\ValidatorHandler
{
public function handle($item): bool
{
return isset($item);
}
}