<commit_before>import { ReadonlyContext } from './context';

export type Location = 'body' | 'cookies' | 'headers' | 'params' | 'query';
export type Meta = { req: Request; location: Location; path: string };

export type CustomValidator = (input: any, meta: Meta) => any;
export type StandardValidator = (input: string, ...options: any[]) => boolean;

export type CustomSanitizer = (input: any, meta: Meta) => any;
export type StandardSanitizer = (input: string, ...options: any[]) => any;

export type DynamicMessageCreator = (value: any, meta: Meta) => any;

export interface FieldInstance {
  path: string;
  originalPath: string;
  location: Location;
  value: any;
  originalValue: any;
}

export type ValidationError =
  | {
      // It's optional and undefined so places don't need to define it, but can reference it
      location?: undefined;
      param: '_error';
      msg: any;
      nestedErrors: ValidationError[];
    }
  | {
      location: Location;
      param: string;
      value: any;
      msg: any;
    };

export interface Request {
  [k: string]: any;
  body?: any;
  cookies?: Record<string, any>;
  headers?: Record<string, any>;
  params?: Record<string, any>;
  query?: Record<string, any>;
}

export const contextsSymbol = Symbol('express-validator#contexts');

export interface InternalRequest extends Request {
  [contextsSymbol]?: ReadonlyContext[];
}

export type Middleware = (req: Request, res: any, next: (err?: any) => void) => void;

export class ValidationHalt extends Error {}<commit_msg>Make all props of ValidationError available in all union branches (#794)<commit_after>import { ReadonlyContext } from './context';

export type Location = 'body' | 'cookies' | 'headers' | 'params' | 'query';
export type Meta = { req: Request; location: Location; path: string };

export type CustomValidator = (input: any, meta: Meta) => any;
export type StandardValidator = (input: string, ...options: any[]) => boolean;

export type CustomSanitizer = (input: any, meta: Meta) => any;
export type StandardSanitizer = (input: string, ...options: any[]) => any;

export type DynamicMessageCreator = (value: any, meta: Meta) => any;

export interface FieldInstance {
  path: string;
  originalPath: string;
  location: Location;
  value: any;
  originalValue: any;
}

export type ValidationError =
  | {
      param: '_error';
      msg: any;
      nestedErrors: ValidationError[];
      // These are optional so places don't need to define them, but can reference them
      location?: undefined;
      value?: undefined;
    }
  | {
      location: Location;
      param: string;
      value: any;
      msg: any;
      // This is optional so places don't need to define it, but can reference it
      nestedErrors?: unknown[];
    };

export interface Request {
  [k: string]: any;
  body?: any;
  cookies?: Record<string, any>;
  headers?: Record<string, any>;
  params?: Record<string, any>;
  query?: Record<string, any>;
}

export const contextsSymbol = Symbol('express-validator#contexts');

export interface InternalRequest extends Request {
  [contextsSymbol]?: ReadonlyContext[];
}

export type Middleware = (req: Request, res: any, next: (err?: any) => void) => void;

export class ValidationHalt extends Error {}
{'fraction_non_alphanumeric': 0.13095604057792806, 'fraction_numerical': 0.0009222256378727329, 'mean_word_length': 3.9228441754916794, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 25, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5950088', 'n_tokens_mistral': 938, 'n_tokens_neox': 927, 'n_words': 339}