{"record":{"id":"e113c2f744f02cb9","repo":"jquense/yup","slug":"only-valid-options-for-round-are-avail-join","errorCode":null,"errorMessage":"Only valid options for round() are: ${avail.join(', ')}","messagePattern":"Only valid options for round\\(\\) are: (.+?)","errorType":"exception","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"src/number.ts","lineNumber":146,"sourceCode":"      message,\n      skipAbsent: true,\n      test: (val) => Number.isInteger(val),\n    });\n  }\n\n  truncate() {\n    return this.transform((value) => (!isAbsent(value) ? value | 0 : value));\n  }\n\n  round(method?: 'ceil' | 'floor' | 'round' | 'trunc') {\n    let avail = ['ceil', 'floor', 'round', 'trunc'];\n    method = (method?.toLowerCase() as any) || ('round' as const);\n\n    // this exists for symemtry with the new Math.trunc\n    if (method === 'trunc') return this.truncate();\n\n    if (avail.indexOf(method!.toLowerCase()) === -1)\n      throw new TypeError(\n        'Only valid options for round() are: ' + avail.join(', '),\n      );\n\n    return this.transform((value) =>\n      !isAbsent(value) ? Math[method!](value) : value,\n    );\n  }\n}\n\ncreate.prototype = NumberSchema.prototype;\n\n//\n// Number Interfaces\n//\n\nexport default interface NumberSchema<\n  TType extends Maybe<number> = number | undefined,\n  TContext = AnyObject,","sourceCodeStart":128,"sourceCodeEnd":164,"githubUrl":"https://github.com/jquense/yup/blob/ff31eee8a2b10c938bb3a22544d9e33957a8cf01/src/number.ts#L128-L164","documentation":"yup's number.round() delegates to a Math method (round, floor, ceil, trunc). This TypeError is thrown when the optional `roundType` argument is not one of the supported method names. It fails fast instead of silently calling an undefined Math function at transform time.","triggerScenarios":"Calling numberSchema.round('closer'), .round('Round'), or any string not in the avail list; the argument is lowercased before the check so only exact supported words pass.","commonSituations":"Typo in the rounding mode ('floorr'), copying code from another library that uses different mode names, or dynamically passing a user-supplied mode string.","solutions":["Use one of the exact supported strings: 'round', 'floor', 'ceil', or 'trunc' (case-insensitive)","Call .truncate() directly instead of .round('trunc')","For custom rounding, use numberSchema.transform(v => Math.fround(v)) or a similar transform"],"exampleFix":"// before\nyup.number().round('nearest');\n// after\nyup.number().round('round');","handlingStrategy":"validation","validationCode":"const ROUND_MODES = ['round','floor','ceil','trunc'];\nfunction isValidRoundMode(m) { return typeof m === 'string' && ROUND_MODES.includes(m.toLowerCase()); }\nif (!isValidRoundMode(mode)) mode = 'round';","typeGuard":"function isRoundMode(m: unknown): m is 'round'|'floor'|'ceil'|'trunc' {\n  return typeof m === 'string' && ['round','floor','ceil','trunc'].includes(m.toLowerCase() as any);\n}","tryCatchPattern":"try { schema.round(mode); } catch (e) { if (e instanceof TypeError) schema.round('round'); else throw e; }","preventionTips":["Use a string-literal union type for the mode parameter","Keep a constant list of valid modes next to schema definitions","Prefer .truncate() over .round('trunc') for clarity"],"tags":["api-misuse","typeerror","number-schema"],"backgroundTag":"invalid-enum-value","analyzedSha":"ff31eee8a2b10c938bb3a22544d9e33957a8cf01","analyzedAt":"2026-08-31T21:51:03.773Z","schemaVersion":2},"datasetVersion":"2026-08-31T22:30:34.772Z"}