1. Go to this page and download the library: Download codes50/validation 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/ */
use Codes50\Core\CoreValidator;
class CustomValidator extends CoreValidator
{
public function __construct(array $data = [], array $rules = [])
{
parent::__construct($data, $rules);
}
}
use Codes50\Core\CoreValidator;
class Validator extends CoreValidator
{
public const ATTR_TEST = 'attr_test';
public function __construct(array $data = [], array $rules = [])
{
parent::__construct($data, $rules);
$this->registerAttrPlugin(self::ATTR_TEST, "checkAttrTest");
}
/**
* @param $data
* @return bool
*/
protected function checkAttrTest($data): bool
{
$this->_error = "testmessage";
return false;
}
}
use Codes50\Core\CoreValidator;
class Validator extends CoreValidator
{
public const TYPE_TEST = 'type_test';
public const ATTR_TEST = 'attr_test';
public function __construct(array $data = [], array $rules = [])
{
parent::__construct($data, $rules);
$this->registerTypePlugin(self::TYPE_TEST, "checkTest", [self::ATTR_TEST, self::ATTR_MIN_LENGTH, self::ATTR_MAX_LENGTH]);
$this->registerAttrPlugin(self::ATTR_TEST, "checkAttrTest");
}
/**
* @param $data
* @return bool
*/
protected function checkTest($data): bool
{
// $this->_error = "testmessage";
return true;
}
/**
* @param $data
* @return bool
*/
protected function checkAttrTest($data): bool
{
$this->_error = "testmessage";
return false;
}
}
use Codes50\Core\CoreValidator;
class Validator extends CoreValidator
{
public function __construct(array $data = [], array $rules = [])
{
parent::__construct($data, $rules);
// $this->setLanguage("en");
// $this->setLanguage("tr");
// $this->setLanguage("{your_directory}/custom_language.php", true);
}
}
return [
"plugin_method_not_avaliable" => "Extension method not found for defined control type.",
"plugin_not_avaliable" => "No defined control type!",
"is_ter a larger number.",
"length_max_exceed" => "You have exceeded the number of characters!",
"length_min_exceed" => "Insufficient Number of Characters",
"invalid_regexp" => "This field does not match.",
"invalid_int" => "This field can only be a number.",
"invalid_double" => "This field can only receive numeric or decimal data.",
"invalid_email" => "Invalid email address",
"invalid_boolean" => "Invalid data type",
"invalid_url" => "Invalid URL",
"invalid_domain" => "Invalid domain address",
"invalid_ip" => "Invalid IP address",
"invalid_ipv4" => "Invalid IP address. Must only be of type ipv4.",
"invalid_ipv6" => "Invalid IP address. Must only be of type ipv6.",
"invalid_mac" => "Invalid MAC address",
"invalid_weak_password" => "Invalid password. Your password must contain at least one uppercase letter, a lowercase letter, a number, and a special character.",
"invalid_date" => "Invalid data. This field can only be date.",
"invalid_option" => "Invalid data type"
];