Suggestion: Laravel validation sugar syntax for unique + ignore this + ignore case #55259
Unanswered
robsontenorio
asked this question in
Ideas
Replies: 1 comment 4 replies
-
You don't need to add a custom rule to make the rule case insensitive, you can just expand framework/src/Illuminate/Validation/Concerns/ValidatesAttributes.php Lines 987 to 1032 in 6a08dbd This then could be defined as 'name' => ['required', 'unique:users,name,ignore_case']
// or
'name' => ['required', Rule::unique('users', 'name')->ignoreCase()] Ignoring the record itself is already possible: framework/src/Illuminate/Validation/Rules/Unique.php Lines 27 to 44 in 6a08dbd 'name' => ['required', Rule::unique('users', 'name')->ignore($this->name, 'name')] |
Beta Was this translation helpful? Give feedback.
4 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Yes, I know I can create a custom RULE.
A good addition to the framework would be introduce a sugar syntax validation for this scenario:
Today we can do this ...
But it misses the ability to ignore the record itself and ignore the string case. Some database are string case sensitive. So, "Joe" is different from "JOE"
Maybe something like this?
Beta Was this translation helpful? Give feedback.
All reactions