{"id":"1f9f4af9579b572c","repo":"drizzle-team/drizzle-orm","slug":"length-of-phone-number-template-is-shorter-than-db","errorCode":null,"errorMessage":"Length of phone number template is shorter than db column length restriction: ${this.stringLength}. \n\t\t\t\t\tSet the maximum string length to at least ${template.length}.","messagePattern":"Length of phone number template is shorter than db column length restriction: (.+?)\\. \n\t\t\t\t\tSet the maximum string length to at least (.+?)\\.","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"drizzle-seed/src/services/Generators.ts","lineNumber":1915,"sourceCode":"\t\tplaceholdersCount?: number;\n\t\tprefixesArray: string[];\n\t\tgeneratedDigitsNumbers: number[];\n\t\tgeneratorsMap: Map<string, GenerateUniqueInt>;\n\t\tphoneNumbersSet: Set<string>;\n\t} | undefined;\n\tpublic override isUnique = true;\n\n\toverride init({ count, seed }: { count: number; seed: number }) {\n\t\tsuper.init({ count, seed });\n\n\t\tlet { generatedDigitsNumbers } = this.params;\n\t\tconst { prefixes, template } = this.params;\n\n\t\tconst rng = prand.xoroshiro128plus(seed);\n\n\t\tif (template !== undefined) {\n\t\t\tif (this.stringLength !== undefined && this.stringLength < template.length) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Length of phone number template is shorter than db column length restriction: ${this.stringLength}. \n\t\t\t\t\tSet the maximum string length to at least ${template.length}.`,\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tconst iterArray = [...template.matchAll(/#/g)];\n\t\t\tconst placeholdersCount = iterArray.length;\n\n\t\t\tconst maxUniquePhoneNumbersCount = Math.pow(10, placeholdersCount);\n\t\t\tif (maxUniquePhoneNumbersCount < count) {\n\t\t\t\tthrow new RangeError(\n\t\t\t\t\t`count exceeds max number of unique phone numbers(${maxUniquePhoneNumbersCount}).`,\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tconst generatorsMap = new Map<string, GenerateUniqueInt>();\n\t\t\tconst genObj = new GenerateUniqueInt({ minValue: 0, maxValue: maxUniquePhoneNumbersCount - 1 });\n\t\t\tgenObj.init({","sourceCodeStart":1897,"sourceCodeEnd":1933,"githubUrl":"https://github.com/drizzle-team/drizzle-orm/blob/b7862528fd8fc39bc2653a6c18dad7c1f4e68d10/drizzle-seed/src/services/Generators.ts#L1897-L1933","documentation":"Error \"Length of phone number template is shorter than db column length restriction: ${this.stringLength}. \n\t\t\t\t\tSet the maximum string length to at least ${template.length}.\" thrown in drizzle-team/drizzle-orm.","triggerScenarios":"Phone-number template produces strings longer than the column's length restriction.","commonSituations":"Template with many digit placeholders on a short varchar; align column length with template length.","solutions":["Increase the column's maximum string length to at least the phone template length, or shorten the template."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"analyzedSha":"b7862528fd8fc39bc2653a6c18dad7c1f4e68d10","analyzedAt":"2026-08-03T18:11:14.318Z","schemaVersion":2}