mirror of
https://github.com/codeigniter4/CodeIgniter4.git
synced 2025-02-20 11:44:28 +08:00
[ci skip] Methods to retrieve validation info
This commit is contained in:
parent
ecfe1fec77
commit
867ffcc845
@ -1153,6 +1153,43 @@ class Model
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Returns the model's defined validation rules so that they
|
||||
* can be used elsewhere, if needed.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getValidationRules(array $options=[])
|
||||
{
|
||||
$rules = $this->validationRules;
|
||||
|
||||
if (isset($options['except']))
|
||||
{
|
||||
$rules = array_diff_key($rules, array_flip($options['except']));
|
||||
}
|
||||
elseif (isset($options['only']))
|
||||
{
|
||||
$rules = array_intersect_key($rules, array_flip($options['only']));
|
||||
}
|
||||
|
||||
return $rules;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Returns the model's define validation messages so they
|
||||
* can be used elsewhere, if needed.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getValidationMessages()
|
||||
{
|
||||
return $this->validationMessages;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* A simple event trigger for Model Events that allows additional
|
||||
* data manipulation within the model. Specifically intended for
|
||||
|
Loading…
x
Reference in New Issue
Block a user