---
title: domain
description: Creates a domain validation action.
source: /actions/domain/domain.ts
contributors:
  - yslpn
---

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

# domain

Creates a [domain name](https://en.wikipedia.org/wiki/Domain_name) validation action.

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

## Generics

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

## Parameters

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

### Explanation

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

> Validates ASCII domains. Limits: 63 chars per label, 253 chars total. <Link href="https://en.wikipedia.org/wiki/Internationalized_domain_name">Internationalized domain names</Link> (IDNs) are not supported, including Punycode-encoded labels.
> If you need to validate a full URL (including protocol, path, query, etc.), use the <Link href="../url/">`url`</Link> action.

## Returns

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

## Examples

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

### Domain schema

Schema to validate a domain.

```ts
const DomainSchema = v.pipe(
  v.string(),
  v.nonEmpty('Please enter your domain.'),
  v.domain('The domain is badly formatted.')
);
```

## Related

The following APIs can be combined with `domain`.

### Schemas

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

### Methods

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

### Utils

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