49 lines
1.3 KiB
TypeScript
49 lines
1.3 KiB
TypeScript
/**
|
|
* Data Validator
|
|
* Verify data structure cho từng game code
|
|
*
|
|
* Usage:
|
|
* ```typescript
|
|
* import { validateGameData, DataValidator } from 'game-iframe-sdk/client';
|
|
*
|
|
* const result = validateGameData('G001', receivedData);
|
|
* if (!result.valid) {
|
|
* console.error('Invalid data:', result.errors);
|
|
* }
|
|
* ```
|
|
*/
|
|
import { GameCode } from '../kit/GameDataHandler';
|
|
export interface ValidationResult {
|
|
valid: boolean;
|
|
errors: string[];
|
|
warnings: string[];
|
|
}
|
|
export interface FieldSchema {
|
|
type: 'string' | 'number' | 'boolean' | 'array' | 'object' | 'any';
|
|
required: boolean;
|
|
arrayItemType?: 'string' | 'number' | 'object' | 'any';
|
|
description?: string;
|
|
}
|
|
export interface ItemSchema {
|
|
[field: string]: FieldSchema;
|
|
}
|
|
/**
|
|
* Validate game data payload
|
|
*/
|
|
export declare function validateGameData(gameCode: GameCode, payload: any): ValidationResult;
|
|
/**
|
|
* Get schema for a game code
|
|
*/
|
|
export declare function getSchema(gameCode: GameCode): ItemSchema | null;
|
|
/**
|
|
* Get schema documentation for a game code
|
|
*/
|
|
export declare function getSchemaDoc(gameCode: GameCode): string;
|
|
export declare class DataValidator {
|
|
private gameCode;
|
|
constructor(gameCode: GameCode);
|
|
validate(payload: any): ValidationResult;
|
|
getSchema(): ItemSchema | null;
|
|
getSchemaDoc(): string;
|
|
}
|
|
//# sourceMappingURL=DataValidator.d.ts.map
|