Pure Utilities & Type Guards
Utilities & Type Guards Reference
antd-dynamic-ui ships with 15+ zero-dependency utility functions, schema generators, and 100% dogfooded type guards. Every component inside the library strictly dogfoods these guards to prevent runtime crashes.
Interactive Live Utilities Sandbox
Test the runtime utility functions live in your browser:
isSafeUrl(https://example.com/api) =>true
| Utility Name | Category | Type Signature | Return Type | Details |
|---|---|---|---|---|
| generateZodSchema | Form & Validation | generateZodSchema(rows: FieldConfig[][]): z.ZodObject<any> | z.ZodObject<any> (executable Zod schema) | ▲ Hide |
DescriptionTraverses a 2D matrix of field configurations and dynamically generates a fully typed Zod validation schema, applying rules for required fields, min/max length, regex patterns, email validation, and custom error messages. Parametersrows(FieldConfig[][])— 2D array of form field definitions. Practical Code ExamplesgenerateZodSchema.basic.tstypescript
generateZodSchema.advanced.tstypescript
generateZodSchema.integration.tsxtypescript
| ||||
| getInitialValues | Form & Validation | getInitialValues(rows: FieldConfig[][]): Record<string, any> | Record<string, any> | ▼ Expand |
| validatePhoneNumber | Form & Validation | validatePhoneNumber(phone: string, countryCode?: string): boolean | boolean | ▼ Expand |
| api | API & Network | api: VelocityInstance | VelocityInstance | ▼ Expand |
| uploadApi | API & Network | uploadApi(url: string, file: File | FormData, options?: any): Promise<any> | Promise<any> | ▼ Expand |
| isSafeUrl | Security & Sanitization | isSafeUrl(url?: string): boolean | boolean (true if protocol is http, https, mailto, or tel) | ▼ Expand |
| adjustColor | Formatters & Colors | adjustColor(hex: string, amount: number): string | string (adjusted hex color) | ▼ Expand |
| numberToWords | Formatters & Colors | numberToWords(num: number): string | string (e.g. 'One Thousand Two Hundred Fifty') | ▼ Expand |
| isArray | Type Guards | isArray(val: unknown): val is any[] | val is any[] | ▼ Expand |
| isNotEmptyArray | Type Guards | isNotEmptyArray<T>(val: unknown): val is NonNullable<T[]> | val is NonNullable<T[]> | ▼ Expand |
| isObject | Type Guards | isObject(val: unknown): val is Record<string, any> | val is Record<string, any> | ▼ Expand |
| isNotEmptyObject | Type Guards | isNotEmptyObject<T extends object>(val: unknown): val is NonNullable<T> | val is NonNullable<T> | ▼ Expand |
| isString | Type Guards | isString(val: unknown): val is string | val is string | ▼ Expand |
| isNumber | Type Guards | isNumber(val: unknown): val is number | val is number | ▼ Expand |
| isNotEmpty | Type Guards | isNotEmpty(val: unknown): boolean | boolean | ▼ Expand |