import { ArrayValidator, ArrayValidatorConstructorParams } from './array'; import { FieldValidators, ObjectValidator, ObjectValidatorConstructorParams } from './object'; import { TypeGuardValidator, TypeGuardValidatorConstructorParams } from './typeGuard'; import { TypeGuardWithContext } from './common'; import { OneOfValidator, OneOfValidatorConstructorParams } from './oneOf'; import { Validator, ValidatorFunc } from './validator'; /** * A {@link Validation.Classes.StringValidator | StringValidator} which validates a string in place. * @public */ export declare const string: Validator; /** * A {@link Validation.Classes.NumberValidator | NumberValidator} which validates a number in place. * @public */ export declare const number: Validator; /** * A {@link Validation.Classes.BooleanValidator | BooleanValidator} which validates a boolean in place. * @public */ export declare const boolean: Validator; /** * Helper function to create a {@link Validation.Classes.ObjectValidator | ObjectValidator} which validates * an object in place. * @param fields - A {@link Validation.Classes.FieldValidators | field validator definition} * describing the validations to be applied. * @param params - Optional {@link Validation.Classes.ObjectValidatorConstructorParams | parameters} * to refine the behavior of the resulting {@link Validation.Validator | validator}. * @returns A new {@link Validation.Validator | Validator} which validates the desired * object in place. * @public */ export declare function object(fields: FieldValidators, params?: Omit, 'fields'>): ObjectValidator; /** * Helper function to create a {@link Validation.Classes.ArrayValidator | ArrayValidator} which * validates an array in place. * @param validateElement - A {@link Validation.Validator | validator} which validates each element. * @returns A new {@link Validation.Classes.ArrayValidator | ArrayValidator } which validates the desired * array in place. * @public */ export declare function arrayOf(validateElement: Validator, params?: Omit, 'validateElement'>): ArrayValidator; /** * Options for {@link Validators.recordOf} helper function. * @public */ export interface IRecordOfValidatorOptions { /** * If `onError` is `'fail'` (default), then the entire validation fails if any key or element * cannot be validated. If `onError` is `'ignore'`, failing elements are silently ignored. */ onError?: 'fail' | 'ignore'; /** * If present, `keyValidator` is used to validate the source object property names. * @remarks * Can be used to validate key names to supported values and/or strong types. */ keyValidator?: Validator; } /** * A helper function to create a {@link Validation.Validator | Validator} which validates the `string`-keyed properties * using a supplied {@link Validation.Validator | Validator} to produce a `Record`. * @remarks * If present, the supplied {@link Validators.IRecordOfValidatorOptions | options} can provide a strongly-typed * validator for keys and/or control the handling of elements that fail validation. * @param validator - {@link Validation.Validator | Validator} used for each item in the source object. * @param options - Optional {@link Validators.IRecordOfValidatorOptions | IRecordOfValidatorOptions} which * supplies a key validator and/or error-handling options. * @returns A {@link Validation.Validator | Validator} which validates `Record`. * @public */ export declare function recordOf(validator: Validator, options?: IRecordOfValidatorOptions): Validator, TC>; /** * Helper function to create a {@link Validation.Validator} which validates an enumerated * value in place. * @public */ export declare function enumeratedValue(values: ReadonlyArray): Validator>; /** * Helper function to create a {@link Validation.Validator} which validates a literal value. * @param value - the literal value to be validated * @public */ export declare function literal(value: T): Validator; /** * Helper function to create a {@link Validation.Validator | Validator} which validates one * of several possible validated values. * @param validators - the {@link Validation.Validator | validators} to be considered. * @param params - Optional {@link Validation.Classes.OneOfValidatorConstructorParams | params} used to construct the validator. * @returns A new {@link Validator | Validator} which validates values that match any of * the supplied validators. * @public */ export declare function oneOf(validators: Array>, params?: Omit, 'validators'>): OneOfValidator; /** * Helper function to create a {@link Validation.Classes.TypeGuardValidator | TypeGuardValidator} which * validates a value or object in place. * @param description - a description of the thing to be validated for use in error messages * @param guard - a {@link Validation.TypeGuardWithContext} which performs the validation. * @returns A new {@link Validation.Classes.TypeGuardValidator | TypeGuardValidator } which validates * the values using the supplied type guard. * @public */ export declare function isA(description: string, guard: TypeGuardWithContext, params?: Omit, 'description' | 'guard'>): TypeGuardValidator; /** * Helper function to create a {@link Validation.Validator | Validator} using a * supplied {@link Validation.ValidatorFunc | validator function}. * @param validator - A {@link Validation.ValidatorFunc | validator function} that a * supplied unknown value matches some condition. * @returns A new {@link Validation.Validator | Validator} which validates the desired * value using the supplied function. * @public */ export declare function generic(validator: ValidatorFunc): Validator; //# sourceMappingURL=validators.d.ts.map