UNPKG

@afriex/core

Version:

HTTP client, configuration and typed errors for the Afriex Business API SDK

65 lines • 2.29 kB
/** * Builder for constructing validation errors * Provides a fluent API for field validation */ export declare class ValidationBuilder { private errors; /** * Validates that a field is required (not null, undefined, or empty string) * @param field - The field name * @param value - The value to check * @param message - Optional custom error message * @returns This builder for chaining */ required(field: string, value: unknown, message?: string): this; /** * Validates a custom condition * @param field - The field name * @param condition - If true, adds an error * @param message - The error message * @returns This builder for chaining */ condition(field: string, condition: boolean, message: string): this; /** * Validates that two fields are mutually exclusive * @param field1 - First field name * @param value1 - First field value * @param field2 - Second field name * @param value2 - Second field value * @param message - Optional custom error message * @returns This builder for chaining */ mutuallyExclusive(field1: string, value1: unknown, field2: string, value2: unknown, message?: string): this; /** * Validates that at least one of the fields is provided * @param fields - Array of [fieldName, value] tuples * @param message - Optional custom error message * @returns This builder for chaining */ requireOneOf(fields: Array<[string, unknown]>, message?: string): this; /** * Validates a number is positive * @param field - The field name * @param value - The number to check * @param message - Optional custom error message * @returns This builder for chaining */ positive(field: string, value: number | undefined, message?: string): this; /** * Throws a ValidationError if any errors were collected * @throws ValidationError with all collected errors */ throwIfInvalid(): void; /** * Returns true if there are validation errors */ hasErrors(): boolean; /** * Gets all collected errors */ getErrors(): Array<{ field: string; message: string; }>; } //# sourceMappingURL=ValidationBuilder.d.ts.map