---
title: mac
description: Creates a MAC address validation action.
source: /actions/mac/mac.ts
contributors:
  - fabian-hiller
  - ariskemper
---

import { ApiList, Link, Property } from '~/components';
import { properties } from './properties';

# mac

Creates a [MAC address](https://en.wikipedia.org/wiki/MAC_address) validation action.

> This validation action accepts 48-bit and 64-bit MAC addresses. For a more specific validation, you can also use <Link href="../mac48/">`mac48`</Link> or <Link href="../mac64/">`mac64`</Link>.

```ts
const Action = v.mac<TInput, TMessage>(message);
```

## Generics

- `TInput` <Property {...properties.TInput} />
- `TMessage` <Property {...properties.TMessage} />

## Parameters

- `message` <Property {...properties.message} />

### Explanation

With `mac` you can validate the formatting of a string. If the input is not a MAC address, you can use `message` to customize the error message.

## Returns

- `Action` <Property {...properties.Action} />

## Examples

The following examples show how `mac` can be used.

### MAC schema

Schema to validate a MAC address.

```ts
const MacSchema = v.pipe(
  v.string(),
  v.mac('The MAC address is badly formatted.')
);
```

## Related

The following APIs can be combined with `mac`.

### Schemas

<ApiList items={['any', 'custom', 'string']} />

### Methods

<ApiList items={['pipe']} />

### Utils

<ApiList items={['isOfKind', 'isOfType']} />
