Creating a Schema Transform for a Specific Key's Type

Is there a Schema transform that takes a Schema and key of that schema and returns a Schema of that key's type?

export const ModelIdentifier = Schema.Union(
  OpenAiModelIdentifier,
  AnthropicModelIdentifier,
);
export type ModelIdentifier = typeof ModelIdentifier.Type;

export type ModelProvider = ModelIdentifier["provider"];
// Is there a way to get a ModelProvider Schema?


resolved types:
type ModelIdentifier = OpenAiModelIdentifier | AnthropicModelIdentifier
type ModelProvider = "openai" | "anthropic"
Was this page helpful?