diff --git a/system/Model.php b/system/Model.php index ab38b20a1e..c0d6038602 100644 --- a/system/Model.php +++ b/system/Model.php @@ -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