---
title: "TokenSchema"
description: "A `remix/data-schema` schema that also names the token type it declares. Every factory in this module returns one."
url: "https://pitlane.tools/package/theme/schema/interface/TokenSchema"
---

# TokenSchema

```ts
import type { TokenSchema } from "@pitlane/theme/schema";
```

A `remix/data-schema` schema that also names the token type it declares. Every factory in this module returns one.

## See

[color](https://pitlane.tools/package/theme/schema/function/color.md)

## Extends

- `Schema`\<`unknown`, `string`>

## Type Parameters

### tag

`tag` _extends_ `SchemaTag` = `SchemaTag`

## Properties

### \[TAG\]

```ts
readonly [TAG]: tag;
```

---

### \~run

```ts
~run: (value: unknown, context: ValidationContext) => ValidationResult<string>;
```

Internal validator used to validate nested values while preserving `path`/`options`.

#### Parameters

##### value

`unknown`

##### context

`ValidationContext`

#### Returns

`ValidationResult`\<`string`>

#### Inherited from

```ts
Schema.~run
```

---

### \~standard

```ts
~standard: SyncStandardSchemaProps<unknown, string>;
```

#### Inherited from

```ts
Schema.~standard
```

---

### pipe

```ts
pipe: (...checks: Check<string>[]) => Schema<unknown, string>;
```

Compose one or more reusable checks onto this schema.

Checks run after the underlying schema has validated and produced an `output` value. If any check fails, validation fails with an issue (using the check's `message` if provided).

#### Parameters

##### checks

...`Check`\<`string`>\[\]

One or more `Check`s to apply in order

#### Returns

`Schema`\<`unknown`, `string`>

A new schema with the checks applied

#### Inherited from

```ts
Schema.pipe
```

---

### refine

```ts
refine: (predicate: (value: string) => boolean, message?: string) => Schema<unknown, string>;
```

Add an inline predicate check onto this schema.

The predicate runs after the underlying schema has validated and produced an `output` value. If the predicate returns `false`, validation fails with an issue.

#### Parameters

##### predicate

(`value`: `string`) => `boolean`

A function that returns `true` for valid values

##### message?

`string`

Optional issue message when the predicate fails

#### Returns

`Schema`\<`unknown`, `string`>

A new schema with the refinement applied

#### Inherited from

```ts
Schema.refine
```

---

### transform

```ts
transform: <newOutput>(transformer: (value: string) => newOutput) => Schema<unknown, newOutput>;
```

Transform the output of this schema with a function.

The transform function runs after the underlying schema has validated and produced an `output` value. The returned schema has a different output type.

#### Type Parameters

##### newOutput

`newOutput`

#### Parameters

##### transformer

(`value`: `string`) => `newOutput`

A function that transforms the validated output

#### Returns

`Schema`\<`unknown`, `newOutput`>

A new schema with the transformation applied

#### Inherited from

```ts
Schema.transform
```
