I've created a bunch of errors in a file under APPPATH/messages/validate.php
with a bunch of common messages such as...
return array(
'not_empty' => ':field must not be empty.',
'matches' => ':field must be the same as :param1',
'regex' => ':field does not match the required format',
'exact_length' => ':field must be exactly :param1 characters long',
'min_length' => ':field must be at least :param1 characters long',
'max_length' => ':field must be less than :param1 characters long',
'in_array' => ':field must be one of the available options',
'digit' => ':field must be a digit',
'email' => 'You must enter a valid email.',
'name' => 'You must enter your name.',
'enquiry' => 'You must enter your enquiry.',
'captcha' => array (
'Captcha::valid' => 'The characters you entered did not match the image. Please try again.',
'not_empty' => 'You must enter the characters from the image.'
)
);
This works great when I get errors like $errors = $post->errors('validate')
.
Is there a way to use these errors as base errors, and if I have a separate form which needs more, I can use a separate file with only the differences in it, for example it may look like
return array(
'permissions' => 'Please agree to the permissions',
);
So obviously, any email
error message will come from validate.php
(inherited), but any permissions
error will come from the new file with the error definition for permissions
.
I named the file validate.php
because the inherit behaviour seems to work with the system
folder and that is what it is called under SYSPATH/messages/validate.php
(see it on GitHub).
Can my error messages inherit from a base file, or should I just copy all the error messages per form?