I have this validation rule in CodeIgniter:
'bookForm' => array(
array(
'field' => 'title',
'label' => 'Title',
'rules' => 'trim|required|min_length[10]'
)
)
I was wondering if I’m doing this right or wrong, because when I enter a space followed by a string which is 10 in length, it’s supposed to be trim and evaluate if it’s a string 10 in length – which it does.
However, when I try to get the data after it passes validation, the string still has the space in front. Is this the right behavior of CI? I mean i just trimmed data in validation, do I have to trim those once more for storage? If I actually needed the string to be MD5’ed, I would do MD5 on it again after? (Talk about redundancy)
Looking in the docs we can see that indeed the content must be trimmed after the validation.EDIT
A quick test in CI 2.2.0 with the
md5function shows that the POST variable is changed after the validation, avoiding redundancy.