# jwsCompact

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

Creates a [JWS compact serialization](https://datatracker.ietf.org/doc/html/rfc7515#section-3.1) validation action.

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

## Generics

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

## Parameters

- `message` `TMessage`

### Explanation

With `jwsCompact` you can validate that a string matches the three-part compact string shape used by JWS compact serialization with unpadded Base64URL-like segments. If the input does not match this JWS compact string shape, you can use `message` to customize the error message.

> Hint: This validation action only checks the three-part compact string shape. It does not decode the segments, verify the signature, or validate claims. Empty payload and signature segments are accepted when they appear as valid compact-serialization segments. If you need full JWT validation, signature verification, or claim checks, use a dedicated library such as one from [jwt.io/libraries](https://www.jwt.io/libraries).

## Returns

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

## Examples

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

### Access token schema

Schema to validate that an access token string matches the JWS compact string shape.

```ts
const AccessTokenSchema = v.pipe(
  v.string(),
  v.nonEmpty('Provide an access token.'),
  v.jwsCompact('The token must be a valid JWS compact string.')
);
```

## Related

The following APIs can be combined with `jwsCompact`.

### 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)
