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

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

# ipv4

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

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

## Generics

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

## Parameters

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

### Explanation

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

## Returns

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

## Examples

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

### IPv4 schema

Schema to validate an IPv4 address.

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

## Related

The following APIs can be combined with `ipv4`.

### Schemas

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

### Methods

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

### Utils

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