# url

> This document is the Markdown version of [valibot.dev/api/url/](https://valibot.dev/api/url/). For the complete documentation index, see [llms.txt](https://valibot.dev/llms.txt).

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

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

## Generics

- `TInput` `extends string`
- `TMessage` `extends ErrorMessage<UrlIssue<TInput>> | undefined`

## Parameters

- `message` `TMessage`

### Explanation

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

> The value is checked with the [URL parser](https://developer.mozilla.org/en-US/docs/Web/API/URL/URL). This check is not perfect. For example, values like "abc:1234" are accepted.

> If you only need to validate an ASCII domain name, consider the [`domain`](/api/domain.md) action.

## Returns

- `Action` `UrlAction<TInput, TMessage>`

## Examples

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

### URL schema

Schema to validate an URL.

```ts
const UrlSchema = v.pipe(
  v.string(),
  v.nonEmpty('Please enter your url.'),
  v.url('The url is badly formatted.'),
  v.endsWith('.com', 'Only ".com" domains are allowed.')
);
```

## Related

The following APIs can be combined with `url`.

### Schemas

[`any`](/api/any.md), [`custom`](/api/custom.md), [`string`](/api/string.md)

### Methods

[`pipe`](/api/pipe.md)

### Utils

[`isOfKind`](/api/isOfKind.md), [`isOfType`](/api/isOfType.md)
