diff options
author | Andrey Andreev <narf@bofh.bg> | 2012-10-11 19:53:30 +0200 |
---|---|---|
committer | Andrey Andreev <narf@bofh.bg> | 2012-10-11 19:53:30 +0200 |
commit | 7d8b1db8beb82d07695fe0a9266e352724c746ae (patch) | |
tree | e9c4f937c31cc19200b055808edd6409acea21bc /system | |
parent | 06e9d1d7a4c979a43f9f8fa437526b6c7a547cec (diff) | |
parent | f38564d739455f46eb38bcbfaa8e255d0a50defe (diff) |
Merge pull request #1871 from Dentxinho/form_validation_differs
Added validation rule 'differs'
Diffstat (limited to 'system')
-rw-r--r-- | system/language/english/form_validation_lang.php | 1 | ||||
-rw-r--r-- | system/libraries/Form_validation.php | 13 |
2 files changed, 14 insertions, 0 deletions
diff --git a/system/language/english/form_validation_lang.php b/system/language/english/form_validation_lang.php index cf1b3b503..6ff0cc2f4 100644 --- a/system/language/english/form_validation_lang.php +++ b/system/language/english/form_validation_lang.php @@ -42,6 +42,7 @@ $lang['is_numeric'] = 'The %s field must contain only numeric characters.'; $lang['integer'] = 'The %s field must contain an integer.'; $lang['regex_match'] = 'The %s field is not in the correct format.'; $lang['matches'] = 'The %s field does not match the %s field.'; +$lang['differs'] = 'The %s field must differ from the %s field.'; $lang['is_unique'] = 'The %s field must contain a unique value.'; $lang['is_natural'] = 'The %s field must only contain digits.'; $lang['is_natural_no_zero'] = 'The %s field must only contain digits and must be greater than zero.'; diff --git a/system/libraries/Form_validation.php b/system/libraries/Form_validation.php index fccc12afa..6db5bb495 100644 --- a/system/libraries/Form_validation.php +++ b/system/libraries/Form_validation.php @@ -971,6 +971,19 @@ class CI_Form_validation { // -------------------------------------------------------------------- /** + * Differs from another field + * + * @param string + * @param string field + * @return bool + */ + public function differs($str, $field) + { + return ! (isset($this->_field_data[$field]) && $this->_field_data[$field]['postdata'] === $str); + } + + // -------------------------------------------------------------------- + /** * Is Unique * * Check if the input value doesn't already exist |