-
Notifications
You must be signed in to change notification settings - Fork 774
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How do I have multiple custom errors messages? #122
Comments
I started looking into this and then got side tracked. The alternative function
Should also give the templated responses but it just display the generic results.
further investigation pending, thank you for your patience. |
Any updates? |
@Petah update still pending... |
I'm sorry about our late, @Petah, but this feature is available since always, you can check it on version 0.3.9, which is the first version available by composer: <?php
require 'vendor/autoload.php';
use Respect\Validation\Exceptions\ValidationException;
use Respect\Validation\Validator as v;
try {
v::create()
->key(
'foo',
v::length(20)->alnum()
)
->assert([
'foo' => 'Hello, world!',
]);
} catch (ValidationException $exception) {
$errors = $exception->findMessages([
'length' => 'Custom length message.',
'alnum' => 'Custom alnum message.',
]);
print_r($errors);
} Is that what you need? If not fell free to reopen this issue any time. |
How do I have multiple custom errors messages with Respect Validation.
I have some input that I want to validate against multiple validators. And I want a custom error message for each validation.
This is what I tried:
The output is:
I expected it to output both custom error messages.
Idealy I could get an array of messages for 1 input like:
Would give me:
The text was updated successfully, but these errors were encountered: