Skip to content

Default Rules conflicting error message (email Rule) #161

@michaelthedev

Description

@michaelthedev

I have the same issues as this #143 (comment)

Found this in Validation.php

$messageKeys = [

As well as this

if (isset($this->messages[$key])) {

My fix:

  • I added a new key as the first value in $messageKeys
$messageKeys = [
    '*'.$this->messageSeparator.$ruleKey, // new value
    $attributeKey.$this->messageSeparator.$ruleKey,
    $attributeKey,
    $ruleKey
];
  • I added to my custom messages to match the new value
$validation = $validator->validate($data, $rules, [
  'required' => ':attribute is required',
  '*:unique' => ':attribute already exists', // new custom message
  'email' => ':attribute must be a valid email address',
  'numeric' => ':attribute must be numeric',
  'in' => ':attribute must be one of :allowed_values',
]);

This was the first messages it picks on (Line #421) is the custom message and it breaks the loop. The fix work for any other custom rule as long as it matches *:{$ruleKey}

It's a temporary fix and not a very good cause I had to edit files file /vendor folder. If you could look into this, I'd also be happy to create a PR if I find a better solution later on

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions