One nice alternative way to do this is to copy fuel/core/lang/en/validation.php to fuel/app/lang/en/validation.php and then add your custom rule message to that. This way you can set your custom message in other languages, should you need to do so.
For example:
fuel/app/classes/passwordvalidation.php
<?php
class PasswordValidation { public static function _validation_password($val) { return \Validation::_empty($val) || preg_match(\Config::get('regex.password'), $val) > 0; }
public static function _validation_password_is_changed($val, $old_val) { return !($val === Validation::active()->input($old_val)); } }
fuel/app/lang/en/validation.php
<?php
return array( // Overrides for standard validator messages 'required' => ':label must be completed.',
...
// Custom validation rules 'password' => ':label must contain at least one letter, at least one capital letter and at least one number.', 'password_is_changed' => ':label must be different from old password.' );
We do the same. set_message() is more for one-time custom messages or messages you want to set from your custom validation rules which can't be in a global file, for example in case of module code.