PHP code example of kishieel / laravel-form-request-unit
1. Go to this page and download the library: Download kishieel/laravel-form-request-unit 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/ */
kishieel / laravel-form-request-unit example snippets
use Kishieel\RequestUnit\FormRequestValidator;
public function some_example_test()
{
$formRequest = new YourFormRequest();
$data = [
'property_1' => 12,
'property_2' => 'string'
];
$result = $this->validate($formRequest, $data);
// ..
}
use Kishieel\RequestUnit\FormRequestValidator;
public function some_example_test()
{
// ..
$this->assertFalse($result->passes());
$this->assertArrayHasKey('property_3', $result->errors());
}
use Kishieel\RequestUnit\FormRequestValidator;
public function some_example_test()
{
// ..
$result = $this->validate($formRequest, $data, ['property_1']);
// will keep errors only for `property_1`
$result->errors();
}
Validator::extend('mac_address', function ($attribute, $value) {
return preg_match('/^([0-9A-Fa-f]{2}[:-]){5}([0-9A-Fa-f]{2})$/', strval($value));
});
use Kishieel\RequestUnit\FormRequestValidator;
public function some_example_test()
{
$formRequest = new \Kishieel\RequestUnit\FormRequestCreator([
'mac_address' => ''mac_address', $result->errors());
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.