Skip to content
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

creating a rule with a Anonymous class does not allow custom error message #1477

Open
jupitern opened this issue Dec 2, 2024 · 2 comments
Open
Labels
Milestone

Comments

@jupitern
Copy link

jupitern commented Dec 2, 2024

Description:
creating a rule with a Anonymous class does not allow custom error message. Any ideia how it can be done? Thanks

$v = (new v)->key('Address', (new class extends AbstractRule {
        public function validate($input): bool
        {
            return false;
        }
    })->setTemplate("{{name}} is not good!"), true);

try  {
    $v->assert(['Address' => "cvejvn"]);

} catch (NestedValidationException $e) {
    var_dump($e->getFullMessage());
}

Output:

array(1) {
  ["Address"]=>
  string(21) "Address must be valid"
}
@henriquemoody
Copy link
Member

Thank you for reporting! 🐼

This has been fixed in version 3.0, and I although it's a bug, I would not like to spend time fixing it on version 2.3 😅.

I'm sorry, but you're gonna have to wait until I release version 3.0, which will probably be at the beginning of next year.

@henriquemoody henriquemoody added this to the 3.0 milestone Dec 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants