Teki
Rules

MAC Address

Validate MAC addresses with colon or hyphen separators.

Use mac() on string fields to require a valid MAC address.

Teki schema = Teki.fromRules(
    string("mac").required().mac()
);

Both colon and hyphen separators are accepted, and matching is case-insensitive. Mixed separators within a single address are rejected.

ValueValid
AA:BB:CC:DD:EE:FFyes
aa-bb-cc-dd-ee-ffyes
AA:BB-CC:DD:EE:FFno — mixed separators
AA:BB:CC:DD:EEno — too few octets
GG:BB:CC:DD:EE:FFno — non-hex character

Available on

  • string(...)

Annotation equivalent

import dev.ditsche.teki.annotation.MacAddress;

public class DeviceRequest {
    @Required
    @MacAddress
    private String mac;
}

On this page