feat(IGO-34): MAC address validation (Symfony MacAddress)#101
Merged
Conversation
- validate.MacAddress with net.ParseMAC (48-bit only) and Symfony type names - it.IsMacAddress with WithType; is.MACAddress; ErrInvalidMAC and translations - Tests and examples for validate, is, it, and shared constraint suite Co-authored-by: Igor Lazarev <strider2038@yandex.ru>
…ts; AGENTS Made-with: Cursor
Made-with: Cursor # Conflicts: # CHANGELOG.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Implements MAC address validation aligned with Symfony
MacAddress/MacAddressValidator: same default message, sametypestring values, and the same unicast/multicast, local/universal, and broadcast rules on the first octet andff:ff:ff:ff:ff:ff.API
validate.MacAddresswithvalidate.MacAddressType(...)and constantsvalidate.MacAddressTypeAll,MacAddressTypeBroadcast, etc.it.IsMacAddress()withWithType,WithError,WithMessage,When,WhenGroupsis.MACAddress(Go initialism per Code Review Comments)validation.ErrInvalidMAC/message.InvalidMACwith English and Russian translationsBehavior notes
net.ParseMAConly for 48-bit (6-octet) hardware addresses; colon, hyphen, and dot forms accepted byParseMACare supported. EUI-64 and longer addresses parse in Go but are rejected here so behavior stays aligned with Symfony’sFILTER_VALIDATE_MACscope for typical MAC strings.typestrings return the same invalid error as a bad address (Symfony throws at constraint construction; we validate at runtime).Testing
go test -race ./...golangci-lint run(v2.11.4)Closes IGO-34.