import { SimpleSchema } from './SimpleSchema.js'; import { CleanOptions, ObjectToValidate, ValidationError, ValidationOptions } from './types.js'; export default class ValidationContext { name?: string; private readonly _simpleSchema; private readonly _schema; private readonly _schemaKeys; private _validationErrors; /** * @param schema SimpleSchema instance to use for validation * @param name Optional context name, accessible on context.name. */ constructor(schema: SimpleSchema, name?: string); setValidationErrors(errors: ValidationError[]): void; addValidationErrors(errors: ValidationError[]): void; /** * Reset the validationErrors array */ reset(): void; /** * @param key The key to get an error for * @param genericKey The generic version of this key, if already known * @returns The first validation error for this key, if any */ getErrorForKey(key: string, genericKey?: string | null): ValidationError | undefined; /** * @param key The key to check validity for * @param genericKey The generic version of this key, if already known * @returns True if this key is currently invalid; otherwise false. */ keyIsInvalid(key: string, genericKey?: string | null): boolean; /** * @param key The key get the first error message for * @param genericKey The generic version of this key, if already known * @returns The message for the first error for this key, or an empty string */ keyErrorMessage(key: string, genericKey?: string | null): string; /** * Validates the object against the SimpleSchema and sets an array of error objects * @param obj Object to be validated * @param options Validation options * @returns True if valid; otherwise false */ validate(obj: ObjectToValidate, { extendedCustomContext, ignore: ignoreTypes, keys: keysToValidate, modifier: isModifier, mongoObject, upsert: isUpsert }?: ValidationOptions): boolean; isValid(): boolean; validationErrors(): ValidationError[]; clean(doc: Record, options?: CleanOptions): Record; }