{"version":3,"sources":["../../../src/schema/types/common-number.ts"],"sourcesContent":["import Decimal from '../../core/decimal/decimal'\r\nimport ErrorCodes from '../../errors/io-error-codes'\r\nimport ValidationError from '../../errors/io-validation-error'\r\nimport Node from '../../parser/nodes/nodes'\r\n\r\n/**\r\n * All supported number types\r\n */\r\nexport const NUMBER_TYPES = [\r\n  'bigint', 'decimal',\r\n  'int', 'uint', 'float', 'number',       // General number types\r\n  'int8', 'int16', 'int32',               // Size specific number types\r\n  'uint8', 'uint16', 'uint32', 'uint64',  // Unsigned number types\r\n  'float32', 'float64'                    // Floating point number types\r\n]\r\n\r\n/**\r\n * Map for quick type lookup\r\n */\r\nexport const NUMBER_MAP = NUMBER_TYPES.reduce((acc, type) => {\r\n  acc[type] = true\r\n  return acc\r\n}, {} as { [key: string]: boolean })\r\n\r\n/**\r\n * Helper function for throwing validation errors\r\n */\r\nexport function throwError(code: string, memberPath: string, value: any, node?: Node) {\r\n  // Generate appropriate error message based on error code\r\n  let message: string;\r\n\r\n  switch (code) {\r\n    case ErrorCodes.invalidType:\r\n      message = `The '${memberPath}' has an invalid type. ${value}`;\r\n      break;\r\n    case ErrorCodes.invalidRange:\r\n      message = `The '${memberPath}' must be within the specified range, Currently it is ${value}.`;\r\n      break;\r\n    case ErrorCodes.invalidScale:\r\n      message = `The '${memberPath}' has an invalid scale. ${value}`;\r\n      break;\r\n    case ErrorCodes.invalidPrecision:\r\n      message = `The '${memberPath}' has an invalid precision. ${value}`;\r\n      break;\r\n    default:\r\n      message = `The '${memberPath}' validation failed. ${value}`;\r\n  }\r\n\r\n  throw new ValidationError(code, message, node);\r\n}\r\n\r\n/**\r\n * Get the number of integer digits in a decimal\r\n */\r\nexport function getIntegerDigits(decimal: Decimal): number {\r\n  const valueStr = decimal.toString()\r\n  return valueStr.split('.')[0].replace('-', '').length\r\n}\r\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,4BAAuB;AACvB,iCAA4B;AAMrB,MAAM,eAAe;AAAA,EAC1B;AAAA,EAAU;AAAA,EACV;AAAA,EAAO;AAAA,EAAQ;AAAA,EAAS;AAAA;AAAA,EACxB;AAAA,EAAQ;AAAA,EAAS;AAAA;AAAA,EACjB;AAAA,EAAS;AAAA,EAAU;AAAA,EAAU;AAAA;AAAA,EAC7B;AAAA,EAAW;AAAA;AACb;AAKO,MAAM,aAAa,aAAa,OAAO,CAAC,KAAK,SAAS;AAC3D,MAAI,IAAI,IAAI;AACZ,SAAO;AACT,GAAG,CAAC,CAA+B;AAK5B,SAAS,WAAW,MAAc,YAAoB,OAAY,MAAa;AAEpF,MAAI;AAEJ,UAAQ,MAAM;AAAA,IACZ,KAAK,sBAAAA,QAAW;AACd,gBAAU,QAAQ,UAAU,0BAA0B,KAAK;AAC3D;AAAA,IACF,KAAK,sBAAAA,QAAW;AACd,gBAAU,QAAQ,UAAU,yDAAyD,KAAK;AAC1F;AAAA,IACF,KAAK,sBAAAA,QAAW;AACd,gBAAU,QAAQ,UAAU,2BAA2B,KAAK;AAC5D;AAAA,IACF,KAAK,sBAAAA,QAAW;AACd,gBAAU,QAAQ,UAAU,+BAA+B,KAAK;AAChE;AAAA,IACF;AACE,gBAAU,QAAQ,UAAU,wBAAwB,KAAK;AAAA,EAC7D;AAEA,QAAM,IAAI,2BAAAC,QAAgB,MAAM,SAAS,IAAI;AAC/C;AAKO,SAAS,iBAAiB,SAA0B;AACzD,QAAM,WAAW,QAAQ,SAAS;AAClC,SAAO,SAAS,MAAM,GAAG,EAAE,CAAC,EAAE,QAAQ,KAAK,EAAE,EAAE;AACjD;","names":["ErrorCodes","ValidationError"]}