Skip to content

Commit c700420

Browse files
committed
✨ add the setError() and setErrorMessage() methods
Signed-off-by: otengkwame <developerkwame@gmail.com>
1 parent 7bf2467 commit c700420

1 file changed

Lines changed: 24 additions & 1 deletion

File tree

Core/libraries/Base_Form_validation.php

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,18 @@ public function set_error(string $field, string $error)
8181
{
8282
$this->_error_array[$field] = $error;
8383
}
84+
85+
/**
86+
* Alias to the method above
87+
*
88+
* @param string $field Field name
89+
* @param string $error Error message
90+
*
91+
*/
92+
public function setError(string $field, string $error)
93+
{
94+
$this->set_error($field, $error);
95+
}
8496

8597
/**
8698
* To return error message of choice.
@@ -89,12 +101,23 @@ public function set_error(string $field, string $error)
89101
* @param string $message
90102
* @return string
91103
*/
92-
public function set_error_message($message)
104+
public function set_error_message($message = '')
93105
{
94106
$this->ci->lang->load('upload');
95107
return ($this->ci->lang->line($message) == false) ? $message : $this->ci->lang->line($message);
96108
}
97109

110+
/**
111+
* Alias to the method above
112+
*
113+
* @param string $message
114+
* @return string
115+
*/
116+
public function setErrorMessage($message = '')
117+
{
118+
$this->set_error_message($message);
119+
}
120+
98121
public function _execute($row, $rules, $postdata = null, $cycles = 0)
99122
{
100123
log_message('debug', 'called Base_Form_validation::_execute ' . $row['field']);

0 commit comments

Comments
 (0)