CodeIgniter Forums
Validation errors per field AND per rule - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21)
+--- Thread: Validation errors per field AND per rule (/showthread.php?tid=33695)



Validation errors per field AND per rule - El Forum - 09-05-2010

[eluser]sqwk[/eluser]
At the moment CI uses validation error messages per rule. There is already a library to convert them to be field-based (http://codeigniter.com/wiki/Custom_Validation_Errors_per_Field/), but is it possible to have them be field and rule based?

Something like this: (In external language file. Should also work with ->set_message())
Code:
$lang['id_in_db','places']    = "This place does not exist.";
$lang['id_in_db', 'objects']    = "This object does not exist.";
$lang['id_in_db']    = "This ID does not exist.";
Where places or objects are the name of the field that needs to be validated and id_in_db is the validation rule/function. If no field is set, it would default to the standard rule.