import { JSONSchema } from "json-schema-typed"; //#region ../core-internal/src/validators/types.d.ts /** * JSON Schema type definition (JSON Schema Draft 2020-12) * * This uses the object form of JSON Schema (excluding boolean schemas). * While `true` and `false` are valid JSON Schemas, this SDK uses the * object form for practical type safety. * * Re-exported from json-schema-typed for convenience. * @see https://json-schema.org/draft/2020-12/json-schema-core.html */ type JsonSchemaType = JSONSchema.Interface; /** * Result of a JSON Schema validation operation */ type JsonSchemaValidatorResult = { valid: true; data: T; errorMessage: undefined; } | { valid: false; data: undefined; errorMessage: string; }; /** * A validator function that validates data against a JSON Schema */ type JsonSchemaValidator = (input: unknown) => JsonSchemaValidatorResult; /** * Provider interface for creating validators from JSON Schemas * * This is the main extension point for custom validator implementations. * Implementations should: * - Support JSON Schema Draft 2020-12 (or be compatible with it) * - Return validator functions that can be called multiple times * - Handle schema compilation/caching internally * - Provide clear error messages on validation failure * * @example * ```ts source="./types.examples.ts#jsonSchemaValidator_implementation" * class MyValidatorProvider implements jsonSchemaValidator { * getValidator(schema: JsonSchemaType): JsonSchemaValidator { * // Compile/cache validator from schema * return (input: unknown) => * isValid(schema, input) * ? { valid: true, data: input as T, errorMessage: undefined } * : { valid: false, data: undefined, errorMessage: 'Error details' }; * } * } * ``` */ interface jsonSchemaValidator { /** * Create a validator for the given JSON Schema * * @param schema - Standard JSON Schema object * @returns A validator function that can be called multiple times */ getValidator(schema: JsonSchemaType): JsonSchemaValidator; } //#endregion export { jsonSchemaValidator as i, JsonSchemaValidator as n, JsonSchemaValidatorResult as r, JsonSchemaType as t }; //# sourceMappingURL=types-R2RTIcjk.d.mts.map