---
title: ip
description: Creates an IP address validation action.
source: /actions/ip/ip.ts
contributors:
  - fabian-hiller
---

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

# ip

Creates an [IP address](https://en.wikipedia.org/wiki/IP_address) validation action.

> This validation action accepts IPv4 and IPv6 addresses. For a more specific validation, you can also use <Link href="../ipv4/">`ipv4`</Link> or <Link href="../ipv6/">`ipv6`</Link>.

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

## Generics

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

## Parameters

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

### Explanation

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

## Returns

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

## Examples

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

### IP address schema

Schema to validate an IP address.

```ts
const IpAddressSchema = v.pipe(
  v.string(),
  v.ip('The IP address is badly formatted.')
);
```

## Related

The following APIs can be combined with `ip`.

### Schemas

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

### Methods

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

### Utils

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