@gati-framework/runtime
Version:
Gati runtime execution engine for running handler-based applications
89 lines • 2.7 kB
TypeScript
/**
* @module runtime/gtype/examples
* @description Usage examples for the GType validation system
*/
import { type GType } from './index.js';
/**
* Example 1: Simple User Schema
*
* Validates a basic user object with required fields
*/
export declare const userSchema: import("./schema.js").GTypeObject;
/**
* Example 2: Product Schema with Constraints
*
* Demonstrates custom validators and constraints
*/
export declare const productSchema: import("./schema.js").GTypeObject;
/**
* Example 3: API Response Schema with Union Types
*
* Demonstrates union types for success/error responses
*/
export declare const apiResponseSchema: import("./schema.js").GTypeUnion;
/**
* Example 4: Nested Object Schema
*
* Demonstrates nested objects and optional fields
*/
export declare const orderSchema: import("./schema.js").GTypeObject;
/**
* Example 5: Handler Request/Response Schemas
*
* Demonstrates how to use GType for handler validation
*/
export declare const createUserRequestSchema: import("./schema.js").GTypeObject;
export declare const createUserResponseSchema: import("./schema.js").GTypeObject;
/**
* Example 6: Custom Validator
*
* Demonstrates custom validation logic
*/
export declare const passwordSchema: import("./schema.js").GTypePrimitive;
/**
* Example 7: Array with Constraints
*
* Demonstrates array validation with min/max items
*/
export declare const tagListSchema: import("./schema.js").GTypeArray;
/**
* Example 8: Discriminated Union (Type-safe API)
*
* Demonstrates discriminated unions for type-safe APIs
*/
export declare const eventSchema: import("./schema.js").GTypeUnion;
/**
* Example 9: Pagination Schema
*
* Common pagination pattern
*/
export declare const paginationSchema: import("./schema.js").GTypeObject;
export declare const paginatedResponseSchema: <T extends GType>(itemSchema: T) => import("./schema.js").GTypeObject;
/**
* Example 10: Optional and Nullable Fields
*
* Demonstrates the difference between optional and nullable
*/
export declare const profileSchema: import("./schema.js").GTypeObject;
/**
* Helper function to validate and throw on error
*/
export declare function validateOrThrow<T>(value: unknown, schema: GType, name?: string): asserts value is T;
/**
* Helper function to validate with type guard
*/
export declare function isValid<T>(value: unknown, schema: GType): value is T;
/**
* Example usage in a handler
*/
export declare function exampleHandlerUsage(): {
id: string;
name: string;
email: string;
createdAt: string;
};
/**
* Example: Type-safe validation with type guards
*/
export declare function exampleTypeGuard(): void;
//# sourceMappingURL=examples.d.ts.map