---
title: startsWith
description: Creates a starts with validation action.
source: /actions/startsWith/startsWith.ts
contributors:
  - fabian-hiller
---

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

# startsWith

Creates a starts with validation action.

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

## Generics

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

## Parameters

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

### Explanation

With `startsWith` you can validate the start of a string. If the start does not match the `requirement`, you can use `message` to customize the error message.

## Returns

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

## Examples

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

### HTTPS URL schema

Schema to validate a HTTPS URL.

```ts
const HttpsUrlSchema = v.pipe(v.string(), v.url(), v.startsWith('https://'));
```

## Related

The following APIs can be combined with `startsWith`.

### Schemas

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

### Methods

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

### Utils

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