Thanks to visit codestin.com Credit goes to github.com
We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
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
Right now, the Unique constraint sees the following values as different:
This is correct, but what if an user needs to ensure that a value has not been passed more than once (no matter if it's in lowercase/uppercase)?
My suggestion would be to add an option like:
@Assert\Unique(caseInsensitive=true)
The Unique constraint will then see both values ("Sun" & "sun") as the same and will add a violation.
To make this change, I would edit both files as follow:
UniqueValidator
Before
foreach ($value as $element) { ... }
After
if ($constraint->caseInsensitive) { $value = array_map('strtolower', $value); // or maybe use mb_strtolower()? } foreach ($value as $element) { ... }
Unique
class Unique extends Constraint { public const IS_NOT_UNIQUE = '7911c98d-b845-4da0-94b7-a8dac36bc55a'; ... }
class Unique extends Constraint { public const IS_NOT_UNIQUE = '7911c98d-b845-4da0-94b7-a8dac36bc55a'; public $caseInsensitive = false; ... }
EDIT: Improved readability
The text was updated successfully, but these errors were encountered:
#37507 looks like a suggestion that would solve this issue too
Sorry, something went wrong.
Let's close in favour of #37507. Having one issue to keep track of this feature request is enough.
No branches or pull requests
Uh oh!
There was an error while loading. Please reload this page.
Description
Right now, the Unique constraint sees the following values as different:
This is correct, but what if an user needs to ensure that a value has not been passed more than once (no matter if it's in lowercase/uppercase)?
Example
My suggestion would be to add an option like:
The Unique constraint will then see both values ("Sun" & "sun") as the same and will add a violation.
To make this change, I would edit both files as follow:
UniqueValidator
Before
After
Unique
Before
After
EDIT: Improved readability
The text was updated successfully, but these errors were encountered: