-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Validator] Add MacAddress
constraint for validating MAC address
#51862
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
Conversation
What about renaming it to |
src/Symfony/Component/Validator/Tests/Constraints/MacValidatorTest.php
Outdated
Show resolved
Hide resolved
src/Symfony/Component/Validator/Tests/Constraints/MacValidatorTest.php
Outdated
Show resolved
Hide resolved
src/Symfony/Component/Validator/Tests/Constraints/MacValidatorTest.php
Outdated
Show resolved
Hide resolved
Mac
constraint for validating mac addressMac
constraint for validating MAC address
For me |
I see what you did there. 🍏 |
I actually find this name more relevant than simply putting |
Hahah, seems I'm so "anti Apple", that I forgot one of the most known names in world... :D I don't think there will be any constraint used in real scenario to check mac devices (mac device names?) - but if, the constraint should be a prefixed with the name of the company, e.g. |
As I said in #51777 (comment) I am not convinced that this is a common enough use case to be part of the Symfony core. |
Yeah, maybe we should encourage releasing niche-y validators as standalone packages more. Then again, we have other network-related constraints, like the already mentioned IP and CIDR. What makes this one different? |
To me a I vote for naming it |
I can work with a client's IP address. But for MAC addresses I do only get the one from the latest hop. |
@Ninos can you please elaborate on your use-case? Thanks |
I vote |
Renamed to
Application e.g. for storing device specific mac addresses |
Mac
constraint for validating MAC addressMacAddress
constraint for validating MAC address
src/Symfony/Component/Validator/Resources/translations/validators.en.xlf
Outdated
Show resolved
Hide resolved
PR rebased ✅ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still GTM. Let's make a decision on this one?
I still don’t see this as a common enough use case, but I won’t insist if others agree with adding this constraint. |
Thank you @Ninos. |
…`UNIVERSAL_*`, `UNICAST_*`, `MULTICAST_*`, `BROADCAST`) in `MacAddress` constraint (Ninos) This PR was squashed before being merged into the 7.1 branch. Discussion ---------- [Validator] Add support for types (`ALL*`, `LOCAL_*`, `UNIVERSAL_*`, `UNICAST_*`, `MULTICAST_*`, `BROADCAST`) in `MacAddress` constraint | Q | A | ------------- | --- | Branch? | 7.1 | Bug fix? | no | New feature? | yes | Deprecations? | no | License | MIT Before some months we added the `MacAddress` contraint to v7.1, see also #51862 This MR also adds support for validating unicast/multicast, local/universal or any (default) mac address versions. For more informations, see: https://en.wikipedia.org/wiki/MAC_address#Ranges_of_group_and_locally_administered_addresses ~~PS: May we should rename `PRIVATE` & `PUBLIC` to `LOCAL` & `UNIVERSAL` to be a bit more consistent with naming in mac address standard. Also then maybe `version` attribute to `type`. .. Just let me know (already prepared changes locally) :-)~~ Commits ------- 16b9210 [Validator] Add support for types (`ALL*`, `LOCAL_*`, `UNIVERSAL_*`, `UNICAST_*`, `MULTICAST_*`, `BROADCAST`) in `MacAddress` constraint
Possibility to validate against mac address.
See also past discussion: #51777