neumorphic-peripheral
Version:
A lightweight, framework-agnostic JavaScript/TypeScript library for beautiful neumorphic styling
77 lines • 2.17 kB
TypeScript
/**
* Zod Validation Adapter for Neumorphic Peripheral
*
* This adapter allows you to use Zod schemas for validation
* Install: npm install zod
*
* Usage:
* import { z } from 'zod'
* import { zodAdapter } from 'neumorphic-peripheral/adapters/zod'
*
* const schema = z.string().email().min(5)
* np.input(element, { validate: zodAdapter(schema) })
*/
import { ValidationFunction, ValidationResult } from '../types';
type ZodSchema = any;
/**
* Creates a validation function from a Zod schema
*/
export declare function zodAdapter(schema: ZodSchema): ValidationFunction;
/**
* Creates a comprehensive validation function that returns all errors
*/
export declare function zodAdapterDetailed(schema: ZodSchema): (value: string) => ValidationResult;
/**
* Schema builder utilities for common patterns
*/
export declare const zodSchemas: {
email: () => Promise<any>;
password: (minLength?: number) => Promise<any>;
phone: () => Promise<any>;
url: () => Promise<any>;
required: (message?: string) => Promise<any>;
};
/**
* Form-level validation using Zod
*/
export declare class ZodFormValidator {
private schema;
private fields;
constructor(schema: ZodSchema);
/**
* Register a field with its schema key
*/
registerField(element: HTMLElement, key: string): void;
/**
* Validate a specific field
*/
validateField(element: HTMLElement): ValidationResult;
/**
* Validate entire form
*/
validateForm(): {
isValid: boolean;
errors: Record<string, string[]>;
data?: any;
};
private getElementValue;
}
/**
* Helper function to create form validator
*/
export declare function createZodFormValidator(schema: ZodSchema): ZodFormValidator;
/**
* Integration with neumorphic components
*/
export declare const zodIntegration: {
/**
* Setup form validation with Zod schema
*/
setupForm(formElement: HTMLFormElement, schema: ZodSchema, components: Record<string, any>): Promise<ZodFormValidator>;
};
export declare const examples: {
basicField: string;
complexForm: string;
};
export {};
//# sourceMappingURL=zod.d.ts.map