Skip to content

mac ​

Validates that a field contains a valid MAC address.

Options ​

OptionTypeDefaultDescription
messagestringlocale defaultCustom error message

Playground ​

Valid values ​

ValueNotes
"01:23:45:67:89:ab"Colon-separated, lowercase
"01-23-45-67-89-AB"Hyphen-separated, uppercase

Invalid values ​

ValueReason
"ZZ:ZZ:ZZ:ZZ:ZZ:ZZ"Z is not a hex digit
"01:23:45:67:89"Only 5 groups instead of 6

Notes ​

  • Empty string ("") always returns valid: true. Combine with notEmpty to require a value.

Released under the MIT License.