All files / json-type/src constants.ts

100% Statements 26/26
100% Branches 2/2
100% Functions 1/1
100% Lines 26/26

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66                      9x 9x 9x 9x 9x 9x 9x 9x 9x 9x 9x 9x 9x 9x 9x 9x 9x 9x 9x 9x 9x 9x 9x 9x 9x       9x                                                    
/**
 * @module
 * @todo Move to `src/validator/`.
 */
 
/**
 * Validation error codes.
 *
 * ATTENTION: Only add new error codes at the end of the list !!!
 * =========
 */
export enum ValidationError {
  STR = 0,
  NUM,
  BOOL,
  ARR,
  TUP,
  OBJ,
  MAP,
  KEY,
  KEYS,
  BIN,
  OR,
  REF,
  ENUM,
  CONST,
  VALIDATION,
  INT,
  UINT,
  STR_LEN,
  ARR_LEN,
  GT,
  GTE,
  LT,
  LTE,
  BIN_LEN,
}
 
/** Human-readable error messages by error code. */
export const ValidationErrorMessage = {
  [ValidationError.STR]: 'Not a string.',
  [ValidationError.NUM]: 'Not a number.',
  [ValidationError.BOOL]: 'Not a boolean.',
  [ValidationError.ARR]: 'Not an array.',
  [ValidationError.TUP]: 'Not a tuple.',
  [ValidationError.OBJ]: 'Not an object.',
  [ValidationError.MAP]: 'Not a map.',
  [ValidationError.KEY]: 'Missing key.',
  [ValidationError.KEYS]: 'Too many or missing object keys.',
  [ValidationError.BIN]: 'Not a binary.',
  [ValidationError.OR]: 'None of types matched.',
  [ValidationError.REF]: 'Validation error in referenced type.',
  [ValidationError.ENUM]: 'Not an enum value.',
  [ValidationError.CONST]: 'Invalid constant.',
  [ValidationError.VALIDATION]: 'Custom validator failed.',
  [ValidationError.INT]: 'Not an integer.',
  [ValidationError.UINT]: 'Not an unsigned integer.',
  [ValidationError.STR_LEN]: 'Invalid string length.',
  [ValidationError.BIN_LEN]: 'Invalid binary length.',
  [ValidationError.ARR_LEN]: 'Invalid array length.',
  [ValidationError.GT]: 'Value is too small.',
  [ValidationError.GTE]: 'Value is too small.',
  [ValidationError.LT]: 'Value is too large.',
  [ValidationError.LTE]: 'Value is too large.',
};