import { LDLogger, TypeValidator } from '@launchdarkly/js-sdk-common'; /** * A validator that performs structured validation on compound values * (objects, arrays, records, or union types). Returns the validated value * on success, or undefined to preserve the default. * * @param defaults - The current default value for this field, passed from * `validateOptions` so nested defaults propagate without hand-written wrappers. */ export interface CompoundValidator extends TypeValidator { validate(value: unknown, name: string, logger?: LDLogger, defaults?: unknown): { value: unknown; } | undefined; } /** * Validates an options object against a map of validators and defaults. * * If `input` is null, undefined, or not an object the defaults are returned * (with a warning for non-nullish non-objects). * * Supports special validator types created by: * - {@link validatorOf}: recursively validates nested objects * - {@link arrayOf}: validates arrays with per-item validation * - {@link anyOf}: accepts the first matching validator from a list * - {@link recordOf}: validates objects with dynamic keys */ export default function validateOptions(input: unknown, validatorMap: Record, defaults: Record, logger?: LDLogger, prefix?: string): Record; /** * Creates a validator for nested objects. When used in a validator map, * `validateOptions` will recursively validate the nested object's properties. * Defaults for nested fields are passed through from the parent. * * @param validators - Validator map for the nested object's fields. * @param options - Optional configuration. * @param options.defaults - Built-in defaults for nested fields. * @param options.is - Custom `is` predicate. When provided, replaces the * default "is object" check. Use this to discriminate between object shapes * in an `anyOf` (e.g., matching on a `type` discriminant field). */ export declare function validatorOf(validators: Record, options?: { defaults?: Record; is?: (u: unknown) => boolean; }): CompoundValidator; /** * Creates a validator for arrays of discriminated objects. Each item in the * array must be an object containing a `discriminant` field whose value * selects which validator map to apply. The valid discriminant values are * the keys of `validatorsByType`. Items that are not objects, or whose * discriminant value is missing or unrecognized, are filtered out with a * warning. * * @param discriminant - The field name used to determine each item's type. * @param validatorsByType - A mapping from discriminant values to the * validator maps used to validate items of that type. Each validator map * should include a validator for the discriminant field itself. * * @example * ```ts * // Validates an array like: * // [{ type: 'polling', pollInterval: 60 }, { type: 'cache' }] * * const validator = arrayOf('type', { * cache: { type: TypeValidators.String }, * polling: { type: TypeValidators.String, pollInterval: TypeValidators.numberWithMin(30) }, * streaming: { type: TypeValidators.String, initialReconnectDelay: TypeValidators.numberWithMin(1) }, * }); * ``` */ export declare function arrayOf(discriminant: string, validatorsByType: Record>): CompoundValidator; /** * Creates a validator that tries each provided validator in order and uses the * first one whose `is()` check passes. For compound validators the value is * processed through `validate()`; for simple validators the value is accepted * as-is. If no validator matches, a warning is logged and the default is * preserved. * * @example * ```ts * // Accepts either a boolean or a nested object with specific fields: * anyOf(TypeValidators.Boolean, validatorOf({ lifecycle: TypeValidators.Boolean })) * ``` */ export declare function anyOf(...validators: TypeValidator[]): CompoundValidator; /** * Creates a validator for objects with dynamic keys. Each key in the input * object is checked against `keyValidator`; unrecognized keys produce a * warning. Each value is validated by `valueValidator`. Defaults for * individual entries are passed through from the parent so partial overrides * preserve non-overridden entries. * * @param keyValidator - Validates that each key is an allowed value. * @param valueValidator - Validates each value in the record. * @param options - Optional configuration. * @param options.defaults - Built-in defaults for the record entries. When * provided, takes priority over defaults passed from the parent at * validation time (same precedence as {@link validatorOf}). * * @example * ```ts * // Validates a record like { streaming: { ... }, polling: { ... } } * // where keys must be valid connection modes: * recordOf( * TypeValidators.oneOf('streaming', 'polling', 'offline'), * validatorOf({ initializers: arrayValidator, synchronizers: arrayValidator }), * ) * ``` */ export declare function recordOf(keyValidator: TypeValidator, valueValidator: TypeValidator, options?: { defaults?: Record; }): CompoundValidator; //# sourceMappingURL=validateOptions.d.ts.map