[11.x] Improve Email
validation rule custom translation messages
#54202
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Via #54067 we introduced the fluent
Email
validation rule. While implementing this new feature in our project I noticed that the existing custom validation message was not being used.This PR adds tests that test custom validation messages, and makes changes to the
Email
class to make the tests pass. This change alsoThis PR makes the following diff possible:
The
Email
class is quite some slimmer due to now converting to the old rules and then validating that, instead of implementing the different email validation classes. This way the email specific validation and thecustomRules
can just be merged, similar to how theFile
rule works.The
ValidationEmailRuleTest
(andValidationPasswordRuleTest
andValidationFileRuleTest
) are quite confusing, the helper methods are nice for simple tests, but complex tests/cases result in cognitive overload. I would be happy to see if we can simplify these tests, and also test more cases, e.g. the other existing rules don't test custom validation messages.The implementation of the
messages()
method in the differentRule
classes inIlluminate\Validation\Rules
also differ to a confusing extend. Let me know if you are open to receiving follow-up PRs to cleanup the framework in this area.