mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-06-23 20:00:33 -04:00
Enabled santizing input before validation
This commit is contained in:
parent
c061808677
commit
c122987bc7
@ -23,4 +23,22 @@ class CreateDocumentRequest extends DocumentRequest
|
||||
//'file' => 'mimes:jpg'
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Sanitize input before validation.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
/*
|
||||
public function sanitize()
|
||||
{
|
||||
$input = $this->all();
|
||||
|
||||
$input['phone'] = 'test123';
|
||||
|
||||
$this->replace($input);
|
||||
|
||||
return $this->all();
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
@ -2,8 +2,34 @@
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
// https://laracasts.com/discuss/channels/general-discussion/laravel-5-modify-input-before-validation/replies/34366
|
||||
abstract class Request extends FormRequest {
|
||||
|
||||
//
|
||||
|
||||
/**
|
||||
* Validate the input.
|
||||
*
|
||||
* @param \Illuminate\Validation\Factory $factory
|
||||
* @return \Illuminate\Validation\Validator
|
||||
*/
|
||||
public function validator($factory)
|
||||
{
|
||||
return $factory->make(
|
||||
$this->sanitizeInput(), $this->container->call([$this, 'rules']), $this->messages()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sanitize the input.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function sanitizeInput()
|
||||
{
|
||||
if (method_exists($this, 'sanitize'))
|
||||
{
|
||||
return $this->container->call([$this, 'sanitize']);
|
||||
}
|
||||
|
||||
return $this->all();
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user