[API reference](https://evolu.dev/docs/api-reference) › [@evolu/common](https://evolu.dev/docs/api-reference/common) › [Type](https://evolu.dev/docs/api-reference/common/Type) › result

```ts
function result<OkType, ErrType>(
  okType: OkType,
  errType: ErrType,
): UnionType<
  [
    ObjectType<{
      ok: LiteralType<true>;
      value: OkType;
    }>,
    ObjectType<{
      error: ErrType;
      ok: LiteralType<false>;
    }>,
  ]
>;
```

Defined in: [packages/common/src/Type.ts:3690](https://github.com/evoluhq/evolu/blob/e7144e2bbe9069362b62dec1b64a8aa922b8f1b0/packages/common/src/Type.ts#L3690)

Creates a [Type](https://evolu.dev/docs/api-reference/common/Type/interfaces/Type) for [Result](https://evolu.dev/docs/api-reference/common/Result/type-aliases/Result) values.

Use for validating serialized Results from storage, APIs, or message passing.

### Example

```ts
const SyncResponse = result(
  object({ timestamp: NonNegativeInt }),
  typed("SyncError", { message: String }),
);

// Validate response from worker or API
const validated = SyncResponse.from(JSON.parse(message));
if (!validated.ok) return validated; // validation error
// validated.value is Result<{ timestamp }, SyncError>
```