Type Alias: TextCraftInputSchema
TextCraftInputSchema =
ZodObject
<TextCraftInput
>
Defined in: src/textcraft/TextCraftClient.ts:39
Overview
The TextCraftInputSchema
type alias represents a schema for validating input data in the context of the Mika Scraper application. It is built using the Zod
library, which provides a robust way to define and validate complex data structures.
Purpose
This type alias combines various input specifications into a single object schema, ensuring that any data passed to the TextCraft system adheres to the expected format. Utilizing this schema helps maintain data integrity and enhances error handling by validating inputs at runtime.
Structure
The TextCraftInputSchema
is built upon the TextCraftInput
type, encapsulating all necessary fields and constraints required for valid input. It defines the expected data types, required fields, and any validation rules.
Usage
To use the TextCraftInputSchema
for validating inputs, follow these steps:
- Import the schema where you need to validate input data.
- Call the
.parse()
method on the schema with the input data you want to validate.
Example
import { TextCraftInputSchema } from './TextCraftClient';
const inputData = {
// populate with your test data following the TextCraftInput specifications
};
try {
const validatedData = TextCraftInputSchema.parse(inputData);
// validatedData is of the type TextCraftInput
} catch (e) {
console.error('Validation failed:', e.errors);
}
Parameters
As TextCraftInputSchema
is a type alias, it does not have parameters in the traditional sense. Its structure is defined by the TextCraftInput
type, which includes the required fields and their respective data types.
Returns
The parse
method will return an object of type TextCraftInput
upon successful validation. If the input fails validation, it will throw an error containing details about the validation failure.
Additional Information
For more details on the validation rules and the structure of the TextCraftInput
type, refer to the TextCraftInput documentation.