PHP code example of agoalofalife / decompose-validator
1. Go to this page and download the library: Download agoalofalife/decompose-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/ */
agoalofalife / decompose-validator example snippets
use agoalofalife\DecomposeValidator\ValidatorValue;
class ConsumerEmail implements ValidatorValue
{
/**
* @var string
*/
private $attribute;
/**
* @var int
*/
private $exceptConsumerId;
public function __construct(
int $consumerId,
string $attribute = 'email'
) {
$this->exceptConsumerId = $consumerId;
$this->attribute = $attribute;
}
public function getAttribute(): string
{
return $this->attribute;
}
public function getRules(): array
{
return [
'
use agoalofalife\DecomposeValidator\FormRequestDecompose;
class UpdateUserProfile extends FormRequestDecompose
{
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules(): array
{
return [
new ConsumerEmail(),
'name' => ['
/**
* Store a new blog post.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function store(Request $request)
{
$validatorValue = new ConsumerEmail(request->auth()->id);
$validated = $request->validate([
$validatorObject->getAttribute() => $validatorObject->getRules()
]);
//...
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.