Audit Log Validation Schemas (graphql/validation.ts)

webiny-js · packages/api-audit-logs/src/graphql/validation.ts · typescript · MIT
security, integration, fw:zod, tag:validation, tag:audit-logs

Defines Zod schemas for validating GraphQL inputs when fetching and listing audit logs, including IDs, filters, and date ranges. Reuse for audit log API input validation.

// Source: https://github.com/webiny/webiny-js | License: MIT | Copyright Webiny Inc
// Provided via justclaw.it.com; keep this notice with the code.
import zod from "zod";

export const getValidationSchema = zod.object({
    id: zod.string().min(1, "ID is required.")
});

export const listValidationSchema = zod.object({
    where: zod.object({
        app: zod.string().min(1, "App is required.").optional(),
        entity: zod.string().optional(),
        entityId: zod.string().min(1, "Entity ID is required.").optional(),
        createdOn_gte: zod.preprocess(input => {
            if (typeof input == "string" || input instanceof Date) {
                return new Date(input);
            }
            return undefined;
        }, zod.date().optional()),
        createdOn_lte: zod.preproc

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key