Skip to main content

๐Ÿ›ก๏ธ Schema System Demo

Distributed component-owned schema validation with automatic registration and comprehensive error handling. Each component owns its schema for better maintainability and isolation.

๐Ÿ“Š Schema System Overview

๐Ÿ”ง System Status

  • โœ… Registered Schemas: 0
  • โœ… Architecture: Distributed component-owned
  • โœ… Validation Library: Zod with TypeScript
  • โœ… Auto-Registration: Global schema registry

๐ŸŽฏ Active Schemas

    ๐Ÿงช Interactive Schema Testing

    ๐ŸŽจ Theme System

    Validates theme configuration and CSS file references

    Component: ThemeSwitcher

    Test Validation:

    ๐Ÿ—๏ธ Distributed Architecture

    ๐Ÿ“ Component-Owned Schemas

    Each component owns its validation schema:

    src/components/
    โ”œโ”€โ”€ ThemeSwitcher/
    โ”‚   โ”œโ”€โ”€ index.tsx
    โ”‚   โ””โ”€โ”€ schema.ts    โ† Component schema
    โ”œโ”€โ”€ Projects/
    โ”‚   โ”œโ”€โ”€ index.tsx
    โ”‚   โ””โ”€โ”€ schema.ts    โ† Component schema
    โ””โ”€โ”€ .../

    Benefits:

    • โœ… Component isolation
    • โœ… Better maintainability
    • โœ… Easier testing
    • โœ… Clear ownership

    ๐ŸŒ Global Registry

    Automatic schema registration and management:

    // src/schemas/index.ts
    import { validateData } from './index';
    
    // Auto-imports all schemas
    const isValid = validateData(
      'themes', 
      themesData
    );

    Features:

    • โœ… Auto-registration
    • โœ… Centralized validation
    • โœ… Error handling
    • โœ… TypeScript integration

    ๐Ÿ’ป Implementation Examples

    Creating a Component Schema

    // src/components/YourComponent/schema.ts
    import { z } from 'zod';
    
    export const componentSchema = z.object({
      title: z.string(),
      items: z.array(z.object({
        id: z.string(),
        name: z.string(),
        optional: z.string().optional()
      })),
      settings: z.object({
        enabled: z.boolean(),
        maxItems: z.number().min(1).max(100)
      })
    });
    
    export const schemaKey = 'yourComponent';

    Using Schema Validation

    // In your component
    import { validateData } from '@site/src/schemas';
    
    export default function YourComponent(props) {
      // Validate component data
      const isValid = validateData('yourComponent', props.data);
      
      if (!isValid) {
        return React.createElement('div', null, 'Invalid configuration');
      }
      
      return React.createElement('div', null, 'Valid component content');
    }

    ๐ŸŽฏ System Benefits

    ๐Ÿ”ง Development

    • Type-safe validation
    • Better error messages
    • Automatic IntelliSense
    • Catch errors early

    ๐Ÿ—๏ธ Architecture

    • Distributed ownership
    • Modular validation
    • Easy maintenance
    • Clear boundaries

    ๐Ÿš€ Production

    • Runtime validation
    • Graceful degradation
    • Error reporting
    • Configuration safety

    ๐Ÿ”— Related Resources

    Learn more about the schema system and validation architecture: