mirror of
https://github.com/codeigniter4/CodeIgniter4.git
synced 2025-02-20 11:44:28 +08:00
Merge pull request #1787 from atishamte/form_validation
Controller form data validation correction
This commit is contained in:
commit
f53dc688b6
@ -42,7 +42,7 @@ interface ValidationInterface
|
||||
{
|
||||
|
||||
/**
|
||||
* Runs the validation process, returning true/false determing whether
|
||||
* Runs the validation process, returning true/false determining whether
|
||||
* or not validation was successful.
|
||||
*
|
||||
* @param array $data The array of data to validate.
|
||||
@ -50,7 +50,7 @@ interface ValidationInterface
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function run(array $data, string $group = null): bool;
|
||||
public function run(array $data = null, string $group = null): bool;
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
|
||||
@ -86,10 +86,11 @@ interface ValidationInterface
|
||||
* Stores the rules that should be used to validate the items.
|
||||
*
|
||||
* @param array $rules
|
||||
* @param array $messages
|
||||
*
|
||||
* @return \CodeIgniter\Validation\ValidationInterface
|
||||
*/
|
||||
public function setRules(array $rules): ValidationInterface;
|
||||
public function setRules(array $rules, array $messages = []): ValidationInterface;
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
|
||||
@ -120,7 +121,7 @@ interface ValidationInterface
|
||||
|
||||
/**
|
||||
* Returns the array of errors that were encountered during
|
||||
* a run() call. The array should be in the followig format:
|
||||
* a run() call. The array should be in the following format:
|
||||
*
|
||||
* [
|
||||
* 'field1' => 'error message',
|
||||
|
@ -311,13 +311,13 @@ inside the controller::
|
||||
protected $helpers = ['url', 'form'];
|
||||
}
|
||||
|
||||
Validating $_POST data
|
||||
Validating data
|
||||
======================
|
||||
|
||||
The controller also provides a convenience method to make validating $_POST data a little simpler, ``validate()`` that
|
||||
The controller also provides a convenience method to make validating data a little simpler, ``validate()`` that
|
||||
takes an array of rules to test against as the first parameter, and, optionally,
|
||||
an array of custom error messages to display if the items don't pass. Internally, this uses the controller's
|
||||
**$this->request** instance to get the POST data through. The :doc:`Validation Library docs </libraries/validation>`
|
||||
**$this->request** instance to get the data through. The :doc:`Validation Library docs </libraries/validation>`
|
||||
has details on the format of the rules and messages arrays, as well as available rules.::
|
||||
|
||||
public function updateUser(int $userID)
|
||||
|
Loading…
x
Reference in New Issue
Block a user