1. Go to this page and download the library: Download redot/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/ */
redot / validator example snippets
use Redot\Validator\Validator;
/* Instantiate a new validator */
$validator = new Validator($email);
/* Or you can use the static method init */
$validator = Validator::init($email);
/* Apply your rules */
$validator->email()->
use Redot\Validator\Rules\RequiredRule;
Validator::addRule(RequiredRule::class);
Validator::loadDefaultRules();
class CustomRule extends AbstractRule
{
protected string $message = '...';
public function getName(): string
{
// name will be used to call the rule
}
public function validate(mixed $value, mixed ...$params): bool
{
// validation logic
}
}
Validator::setMessages([
'not a valid email.',
'max' => 'The value should be less than or equal to {0}.',
]);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.