[ci skip] Methods to retrieve validation info

This commit is contained in:
Lonnie Ezell 2017-11-26 23:07:27 -06:00
parent ecfe1fec77
commit 867ffcc845
No known key found for this signature in database
GPG Key ID: 8EB408F8D82F5002

View File

@ -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