/** * Validation Helper Functions * * Provides convenience wrappers and higher-level validation utilities * to reduce boilerplate across tools. These helpers build on the core * validation functions from @/lib/validation. */ import { type Result } from '../types/index.js'; import { type PathValidationOptions } from './validation.js'; /** * Parsed components of a Docker image name * * @example * parseImageName('registry.io/org/app:v1.0') * // => { registry: 'registry.io', repository: 'org/app', tag: 'v1.0', fullName: '...' } * * parseImageName('node:20-alpine') * // => { repository: 'node', tag: '20-alpine', fullName: 'node:20-alpine' } */ export interface ParsedImageName { /** Registry hostname (e.g., 'registry.io', 'docker.io') */ registry?: string; /** Repository path (e.g., 'library/node', 'org/app') */ repository: string; /** Image tag (e.g., 'latest', 'v1.0.0', '20-alpine') */ tag: string; /** Full image name as provided */ fullName: string; } /** * Parse Docker image name into components * * Extracts registry, repository, and tag from a Docker image name. * Handles various formats: * - `image:tag` - Docker Hub library image * - `org/image:tag` - Docker Hub organization image * - `registry.io/org/image:tag` - Private registry image * * @param imageName - Full Docker image name * @returns Parsed components or error * * @example * ```typescript * const result = parseImageName('docker.io/library/node:20-alpine'); * if (result.ok) { * const { registry, repository, tag } = result.value; * console.log(`Registry: ${registry}, Repo: ${repository}, Tag: ${tag}`); * } * ``` */ export declare function parseImageName(imageName: string): Result; /** * Validate path and return Result - convenience wrapper * * This is a direct pass-through to validatePath from @/lib/validation, * provided for consistency and discoverability alongside other helpers. * * @param pathInput - Path to validate (relative or absolute) * @param options - Validation options * @returns Validated absolute path or error * * @example * ```typescript * const result = await validatePathOrFail('./src', { * mustExist: true, * mustBeDirectory: true, * }); * if (!result.ok) return result; * const validPath = result.value; * ``` */ export declare function validatePathOrFail(pathInput: string, options?: PathValidationOptions): Promise>; /** * Validate Docker image tag format - convenience alias * * Re-exported from @/lib/validation for consistency with other helpers. * Validates that a tag follows Docker naming conventions. * * @param tag - Docker tag to validate * @returns Validated tag or error * * @example * ```typescript * const result = validateImageTag('v1.0.0-alpha'); * if (result.ok) { * console.log('Valid tag:', result.value); * } * ``` */ export declare function validateImageTag(tag: string): Result; /** * Create a reusable path validator with preset options * * Factory function for creating path validators with common configurations. * Useful for tools that validate multiple paths with the same requirements. * * @param options - Validation options to apply * @returns Validation function * * @example * ```typescript * const validateDirectory = createPathValidator({ * mustExist: true, * mustBeDirectory: true, * }); * * const repoResult = await validateDirectory(input.repositoryPath); * if (!repoResult.ok) return repoResult; * * const moduleResult = await validateDirectory(input.modulePath); * if (!moduleResult.ok) return moduleResult; * ``` */ export declare function createPathValidator(options: PathValidationOptions): (path: string) => Promise>; //# sourceMappingURL=validation-helpers.d.ts.map