Skip to content
0

katanakit-js / useValidate

Function: useValidate() ​

ts
function useValidate<T>(schema, data): FetchResult<T>;

Defined in: src/core/services/validation.service.ts:98

Validates unknown data against a Zod schema and returns a Safe Result. Wrapper sobre ValidationService (backward compatibility).

Type Parameters ​

Type ParameterDescription
TThe validated output type (z.infer of the schema).

Parameters ​

ParameterTypeDescription
schemaZodType<T>Any Zod schema.
dataunknownUnknown input to validate.

Returns ​

FetchResult<T>

FetchResult<T> with typed data or a Validation Error.

Example ​

ts
import { SmartVideoOptionsSchema } from "katanakit-js/schemas";

const result = useValidate(SmartVideoOptionsSchema, JSON.parse(raw));
if (result.ok) useBuildVideoEmbed(result.data);

Released under the MIT License.