1. Go to this page and download the library: Download weew/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/ */
weew / validator example snippets
$constraint = new EmailConstraint();
// or
$constraint = new EmailConstraint('Custom error message.');
$check = $constraint->check('[email protected]');
if ($check) {
// valdiation passed
} else {
echo $constraint->getMessage();
}
$group = new ConstraintGroup('email', [
new EmailConstraint(),
]);
// or
$group = new ConstraintGroup('email');
$group->addConstraint(new EmailConstraint());
$data = new stdClass();
$data->email = '[email protected]';
$validator->check($data);
class User {
protected $username;
public function __construct($username) {
$this->username = $username;
}
public function getUsername() {
return $this->username;
}
}
$validator->check(new User('foo'));
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.