jwsCompact

Creates a JWS compact serialization validation action.

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

Generics

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.

Returns

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.

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

The following APIs can be combined with jwsCompact.

Schemas

Methods

Utils

Contributors

Thanks to all the contributors who helped make this page better!

  • GitHub profile picture of @yslpn

Partners

Thanks to our partners who support the project ideally and financially.

Sponsors

Thanks to our GitHub sponsors who support the project financially.

  • GitHub profile picture of @antfu
  • GitHub profile picture of @UpwayShop
  • GitHub profile picture of @vasilii-kovalev
  • GitHub profile picture of @saturnonearth
  • GitHub profile picture of @ruiaraujo012
  • GitHub profile picture of @hyunbinseo
  • GitHub profile picture of @nickytonline
  • GitHub profile picture of @KubaJastrz
  • GitHub profile picture of @kibertoad
  • GitHub profile picture of @Thanaen
  • GitHub profile picture of @caegdeveloper
  • GitHub profile picture of @bmoyroud
  • GitHub profile picture of @dslatkin