1. Go to this page and download the library: Download expresspaygh/exp-refine 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/ */
expresspaygh / exp-refine example snippets
use Expay\Refine\Filter;
use Expay\Refine\Rules;
$result = (new Filter())
->addField("password", "string")
->addField("email", "email")
->check([
"email" => "[email protected]",
"password" => "hackme"
]);
print_r($result);
use Expay\Refine\Filter;
use Expay\Refine\Rules;
$result = (new Filter())
// add a field type called boolean_value
->addRule("uppercase_bool", new Rules\Boolean('upper'))
->addRules("email", [
new Rules\Required,
new Rules\PHPFilter([
'filter' => FILTER_VALIDATE_EMAIL | FILTER_SANITIZE_EMAIL
])])
->addField("is_admin", "uppercase_bool")
->addField("email", "email")
->check([
"is_admin" => "true",
"email" => "[email protected]"
]);
print_r($result);
use Expay\Refine\Filter;
use Expay\Refine\Rules;
function filter() {
return (new Filter())
// add a field type called boolean_value
->addRule("uppercase_bool", new Rules\Boolean('upper'))
->addRules("email", [
new Rules\Required,
new Rules\PHPFilter([
'filter' => FILTER_VALIDATE_EMAIL | FILTER_SANITIZE_EMAIL
])]);
}
print_r(filter()->check([
"is_admin" => "true",
"email" => "[email protected]"
]));
use Expay\Refine\Filter;
use Expay\Refine\Rules\Rule;
use Expay\Refine\Exceptions\InvalidField;
class CVV extends Rule
{
public function apply($value, string $key, array $request): string
{
if (preg_match("/^\d\d\d$/", $value))
return $value;
throw new InvalidField("Invalid cvv");
}
}
$result = (new Filter())
->addRule("cvv", new CVV)
->check(["cvv" => "123"]);
var_dump($result);
use Expay\Refine\Rules;
use Expay\Refine\Filter;
use Expay\Refine\Exceptions\ValidationError;
try
{
$filter=new Filter;
$vRules=["email"=>"($fields)->check($data);
}
catch(ValidationError $e)
{
$result=$e->getMessage();
}
var_dump($result);
use Expay\Refine\Rules;
use Expay\Refine\Filter;
use Expay\Refine\Exceptions\ValidationError;
use Rakit\Validation\Rule as ValidationRule;
/**
* ValidationRuleObjectProvider
*/
class ValidationRuleObjectProvider extends ValidationRule
{
/**
* message
*
* @var string
*/
protected $message = "";
/**
* __construct
*
* @return void
*/
public function __construct()
{
$this->message=":value is not a valid object";
}
/**
* check
*
* @param mixed $value
* @return bool
*/
public function check($value) : bool
{
return is_object($value);
}
}
try
{
$filter=new Filter;
$vRules=['randomObj'=>'
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.