UNPKG

nuxt-safe-runtime-config

Version:

Validate Nuxt runtime config with Standard Schema at build time

16 lines (15 loc) 707 B
import type { StandardSchemaV1 } from '@standard-schema/spec'; import type { ErrorBehavior } from '../types.js'; export interface ValidationLogger { error: (message: string) => void; warn: (message: string) => void; } export type RuntimeValidationResult = { success: true; value: unknown; } | { success: false; }; export declare function isPromiseLike<T>(value: T | Promise<T>): value is Promise<T>; export declare function validateRuntimeConfig(config: unknown, schema: StandardSchemaV1, onError: ErrorBehavior, logger: ValidationLogger): RuntimeValidationResult | Promise<RuntimeValidationResult>; export declare function isStandardSchema(schema: unknown): schema is StandardSchemaV1;