{"record":{"id":"2d179ef1bd558ede","repo":"can1357/oh-my-pi","slug":"string-length-intersection-is-unsatisfiable","errorCode":null,"errorMessage":"string length intersection is unsatisfiable","messagePattern":"string length intersection is unsatisfiable","errorType":"exception","errorClass":"OmpTypeError","httpStatus":null,"severity":"error","filePath":"packages/omptype/src/type.ts","lineNumber":2087,"sourceCode":"\t\t\t\t\t\t\t}\n\t\t\t\t\t\t: {}),\n\t\t\t\t};\n\t\t\t}\n\t\t}\n\t\tconst extras =\n\t\t\ta.extras === \"reject\" || b.extras === \"reject\"\n\t\t\t\t? \"reject\"\n\t\t\t\t: a.extras === \"delete\" || b.extras === \"delete\"\n\t\t\t\t\t? \"delete\"\n\t\t\t\t\t: \"keep\";\n\t\tconst index = a.index && b.index ? intersect(a.index, b.index) : (a.index ?? b.index);\n\t\treturn { k: \"object\", props, index, extras };\n\t}\n\tif (a.k === \"string\" && b.k === \"string\") {\n\t\tconst min = maxOf(a.min, b.min);\n\t\tconst max = minOf(a.max, b.max);\n\t\tif (min !== undefined && max !== undefined && min > max) {\n\t\t\tthrow new OmpTypeError(\"string length intersection is unsatisfiable\");\n\t\t}\n\t\treturn { k: \"string\", min, max, url: a.url || b.url };\n\t}\n\tif (a.k === \"number\" && b.k === \"number\") {\n\t\tconst min = maxOf(a.min, b.min);\n\t\tconst max = minOf(a.max, b.max);\n\t\tconst xmin = min !== undefined && ((a.min === min && a.xmin === true) || (b.min === min && b.xmin === true));\n\t\tconst xmax = max !== undefined && ((a.max === max && a.xmax === true) || (b.max === max && b.xmax === true));\n\t\tif (min !== undefined && max !== undefined && (min > max || (min === max && (xmin || xmax)))) {\n\t\t\tthrow new OmpTypeError(\"numeric range intersection is unsatisfiable\");\n\t\t}\n\t\tif (a.divisor !== undefined && b.divisor !== undefined && a.divisor !== b.divisor) {\n\t\t\treturn { k: \"intersection\", members: [a, b] };\n\t\t}\n\t\treturn {\n\t\t\tk: \"number\",\n\t\t\tint: a.int || b.int,\n\t\t\tdivisor: a.divisor ?? b.divisor,","sourceCodeStart":2069,"sourceCodeEnd":2105,"githubUrl":"https://github.com/can1357/oh-my-pi/blob/969062200754ea02cfac922e5ebb8c608c079e15/packages/omptype/src/type.ts#L2069-L2105","documentation":"Intersecting two string types intersects their length bounds: min becomes the larger of the two mins and max the smaller of the two maxes. If the resulting min exceeds the resulting max, no string can satisfy both, so the library throws instead of emitting an impossible type.","triggerScenarios":"intersect(string().min(10), string().max(5)) or intersecting a plain string with a constrained one whose bounds no longer overlap after a change.","commonSituations":"A validation rule tightened a min length while another rule capped max length; intersecting a URL-constrained string with a length cap that is too small; off-by-one in manually authored bounds (min > max on one side already).","solutions":["Widen the bounds so min <= max across both operands","Remove the redundant length constraint from one operand","Validate bounds on a single string() builder instead of splitting them across an intersection","Catch OmpTypeError around intersect to report the conflicting bounds"],"exampleFix":"// before\nintersect(string().min(10), string().max(5));\n// after\nintersect(string().min(3), string().max(10));","handlingStrategy":"validation","validationCode":"function stringBoundsOk(specs) {\n  const min = Math.max(...specs.map(s => s.min ?? 0));\n  const max = Math.min(...specs.map(s => s.max ?? Infinity));\n  return min <= max;\n}","typeGuard":"const isOmpTypeError = (e: unknown): e is OmpTypeError => e instanceof OmpTypeError;","tryCatchPattern":"try {\n  const t = intersect(a, b);\n} catch (err) {\n  if (err instanceof OmpTypeError && err.message === 'string length intersection is unsatisfiable') {\n    throw new Error(`String bounds conflict: ${describe(a)} vs ${describe(b)}`);\n  }\n  throw err;\n}","preventionTips":["Check min <= max on every string builder you author","When splitting length rules across layers, keep them in one bounds table","Lint for .min(n) with n greater than any co-intersected .max"],"tags":["types","string","validation","bounds","omptype"],"backgroundTag":"unsatisfiable-type-intersection","analyzedSha":"969062200754ea02cfac922e5ebb8c608c079e15","analyzedAt":"2026-08-31T10:29:35.737Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}