Google Antigravity Directory

The #1 directory for Google Antigravity prompts, rules, workflows & MCP servers. Optimized for Gemini 3 agentic development.

Resources

PromptsMCP ServersAntigravity RulesGEMINI.md GuideBest Practices

Company

Submit PromptAntigravityAI.directory

Popular Prompts

Next.js 14 App RouterReact TypeScriptTypeScript AdvancedFastAPI GuideDocker Best Practices

Legal

Privacy PolicyTerms of ServiceContact Us
Featured on FazierFeatured on WayfindioAntigravity AI - Featured on Startup FameFeatured on Wired BusinessFeatured on Twelve ToolsListed on Turbo0Featured on findly.toolsFeatured on Aura++That App ShowAI ToolzShinyLaunchMillion Dot HomepageSolver ToolsFeatured on FazierFeatured on WayfindioAntigravity AI - Featured on Startup FameFeatured on Wired BusinessFeatured on Twelve ToolsListed on Turbo0Featured on findly.toolsFeatured on Aura++That App ShowAI ToolzShinyLaunchMillion Dot HomepageSolver Tools

© 2026 Antigravity AI Directory. All rights reserved.

The #1 directory for Google Antigravity IDE

This website is not affiliated with, endorsed by, or associated with Google LLC. "Google" and "Gemini" are trademarks of Google LLC.

Antigravity AI Directory
PromptsMCPBest PracticesUse CasesLearn
Home
Prompts
TypeBox Schema Validation

TypeBox Schema Validation

Master TypeBox schema validation for Google Antigravity IDE high-performance APIs

TypeBoxValidationTypeScriptPerformance
by Antigravity AI
⭐0Stars
.antigravity
# TypeBox Schema Validation for Google Antigravity IDE

Build high-performance validation with TypeBox using Google Antigravity IDE. This guide covers schema creation, validation, and integration with Fastify and Elysia.

## Schema Definition

```typescript
// src/schemas/user.ts
import { Type, Static } from "@sinclair/typebox";

export const UserSchema = Type.Object({
  id: Type.String({ format: "uuid" }),
  email: Type.String({ format: "email" }),
  name: Type.String({ minLength: 2, maxLength: 100 }),
  role: Type.Union([Type.Literal("user"), Type.Literal("admin"), Type.Literal("moderator")]),
  avatar: Type.Optional(Type.String({ format: "uri" })),
  settings: Type.Object({
    theme: Type.Union([Type.Literal("light"), Type.Literal("dark"), Type.Literal("system")]),
    notifications: Type.Boolean(),
    language: Type.String({ pattern: "^[a-z]{2}(-[A-Z]{2})?$" }),
  }),
  createdAt: Type.String({ format: "date-time" }),
  updatedAt: Type.String({ format: "date-time" }),
});

export type User = Static<typeof UserSchema>;

export const CreateUserSchema = Type.Omit(UserSchema, ["id", "createdAt", "updatedAt"]);
export type CreateUser = Static<typeof CreateUserSchema>;

export const UpdateUserSchema = Type.Partial(Type.Omit(UserSchema, ["id", "createdAt", "updatedAt"]));
export type UpdateUser = Static<typeof UpdateUserSchema>;

export const UserResponseSchema = Type.Object({
  success: Type.Boolean(),
  data: UserSchema,
});

export const UsersListSchema = Type.Object({
  success: Type.Boolean(),
  data: Type.Array(UserSchema),
  meta: Type.Object({
    total: Type.Integer({ minimum: 0 }),
    page: Type.Integer({ minimum: 1 }),
    limit: Type.Integer({ minimum: 1, maximum: 100 }),
  }),
});
```

## Validation with TypeCompiler

```typescript
// src/lib/validate.ts
import { TypeCompiler, ValueError } from "@sinclair/typebox/compiler";
import { TSchema } from "@sinclair/typebox";

export function createValidator<T extends TSchema>(schema: T) {
  const compiled = TypeCompiler.Compile(schema);

  return {
    validate: (data: unknown): data is Static<T> => compiled.Check(data),
    errors: (data: unknown): ValueError[] => [...compiled.Errors(data)],
    parse: (data: unknown): Static<T> => {
      if (compiled.Check(data)) return data;
      const errors = [...compiled.Errors(data)];
      throw new ValidationError(errors);
    },
  };
}

class ValidationError extends Error {
  constructor(public errors: ValueError[]) {
    super("Validation failed");
    this.name = "ValidationError";
  }

  toResponse() {
    return {
      success: false,
      errors: this.errors.map((e) => ({
        path: e.path,
        message: e.message,
        value: e.value,
      })),
    };
  }
}
```

## Elysia Integration

```typescript
// src/routes/users.ts
import { Elysia, t } from "elysia";
import { UserSchema, CreateUserSchema, UpdateUserSchema } from "@/schemas/user";

export const userRoutes = new Elysia({ prefix: "/users" })
  .get("/", async () => {
    const users = await db.user.findMany();
    return { success: true, data: users };
  }, {
    response: t.Object({
      success: t.Boolean(),
      data: t.Array(UserSchema),
    }),
  })
  .post("/", async ({ body }) => {
    const user = await db.user.create({ data: body });
    return { success: true, data: user };
  }, {
    body: CreateUserSchema,
    response: t.Object({ success: t.Boolean(), data: UserSchema }),
  })
  .patch("/:id", async ({ params, body }) => {
    const user = await db.user.update({ where: { id: params.id }, data: body });
    return { success: true, data: user };
  }, {
    params: t.Object({ id: t.String({ format: "uuid" }) }),
    body: UpdateUserSchema,
    response: t.Object({ success: t.Boolean(), data: UserSchema }),
  });
```

## Best Practices for Google Antigravity IDE

When using TypeBox with Google Antigravity, use TypeCompiler for maximum performance. Create reusable schema compositions. Generate OpenAPI from schemas. Let Gemini 3 generate TypeBox schemas from TypeScript interfaces.

Google Antigravity excels at converting existing types to TypeBox schemas.

When to Use This Prompt

This TypeBox prompt is ideal for developers working on:

  • TypeBox applications requiring modern best practices and optimal performance
  • Projects that need production-ready TypeBox code with proper error handling
  • Teams looking to standardize their typebox development workflow
  • Developers wanting to learn industry-standard TypeBox patterns and techniques

By using this prompt, you can save hours of manual coding and ensure best practices are followed from the start. It's particularly valuable for teams looking to maintain consistency across their typebox implementations.

How to Use

  1. Copy the prompt - Click the copy button above to copy the entire prompt to your clipboard
  2. Paste into your AI assistant - Use with Claude, ChatGPT, Cursor, or any AI coding tool
  3. Customize as needed - Adjust the prompt based on your specific requirements
  4. Review the output - Always review generated code for security and correctness
💡 Pro Tip: For best results, provide context about your project structure and any specific constraints or preferences you have.

Best Practices

  • ✓ Always review generated code for security vulnerabilities before deploying
  • ✓ Test the TypeBox code in a development environment first
  • ✓ Customize the prompt output to match your project's coding standards
  • ✓ Keep your AI assistant's context window in mind for complex requirements
  • ✓ Version control your prompts alongside your code for reproducibility

Frequently Asked Questions

Can I use this TypeBox prompt commercially?

Yes! All prompts on Antigravity AI Directory are free to use for both personal and commercial projects. No attribution required, though it's always appreciated.

Which AI assistants work best with this prompt?

This prompt works excellently with Claude, ChatGPT, Cursor, GitHub Copilot, and other modern AI coding assistants. For best results, use models with large context windows.

How do I customize this prompt for my specific needs?

You can modify the prompt by adding specific requirements, constraints, or preferences. For TypeBox projects, consider mentioning your framework version, coding style, and any specific libraries you're using.

Related Prompts

💬 Comments

Loading comments...