{"record":{"id":"36a44e5f10f7d6f8","repo":"badges/shields","slug":"field-style-must-be-one-of-stylevalues-tostri","errorCode":null,"errorMessage":"Field `style` must be one of (${styleValues.toString()})","messagePattern":"Field `style` must be one of \\((.+?)\\)","errorType":"validation","errorClass":"ValidationError","httpStatus":null,"severity":"error","filePath":"badge-maker/lib/index.js","lineNumber":50,"sourceCode":"        )\n      }\n      format.links.forEach(function (field) {\n        if (typeof field !== 'string') {\n          throw new ValidationError('Field `links` must be an array of strings')\n        }\n      })\n    }\n  }\n\n  const styleValues = [\n    'plastic',\n    'flat',\n    'flat-square',\n    'for-the-badge',\n    'social',\n  ]\n  if ('style' in format && !styleValues.includes(format.style)) {\n    throw new ValidationError(\n      `Field \\`style\\` must be one of (${styleValues.toString()})`,\n    )\n  }\n  if ('idSuffix' in format && !/^[a-zA-Z0-9\\-_]*$/.test(format.idSuffix)) {\n    throw new ValidationError(\n      'Field `idSuffix` must contain only numbers, letters, -, and _',\n    )\n  }\n}\n\nfunction _clean(format) {\n  const expectedKeys = [\n    'label',\n    'message',\n    'labelColor',\n    'color',\n    'style',\n    'logoBase64',","sourceCodeStart":32,"sourceCodeEnd":68,"githubUrl":"https://github.com/badges/shields/blob/766fd8bc89a90b8534dc573ab72dec30215ab1ec/badge-maker/lib/index.js#L32-L68","documentation":"The optional `style` field controls the badge's visual template and must be one of: plastic, flat, flat-square, for-the-badge, social. _validate checks styleValues.includes(format.style) (badge-maker/lib/index.js:49) and throws, listing all allowed values in the message. Unsupported/legacy style names are rejected before rendering.","triggerScenarios":"makeBadge({ message: 'x', style: 'flat-squared' }), style: 'default', style: 'plastic2', or any typo'd/custom style string not in the five-value whitelist.","commonSituations":"Typos in style names, migrating from shields' old styles that were removed (e.g. some legacy styles from gh-badges), building style from user input without whitelisting, or camelCase vs kebab-case confusion ('flatSquare' vs 'flat-square').","solutions":["Use one of the exact allowed values: 'plastic' | 'flat' | 'flat-square' | 'for-the-badge' | 'social'","Default/normalize the style when user input: style: allowedStyles.includes(s) ? s : 'flat'","Check spelling/kebab-case against the list in the error message"],"exampleFix":"// before\nconst svg = makeBadge({ message: 'passing', style: 'flatSquare' })\n// after\nconst svg = makeBadge({ message: 'passing', style: 'flat-square' })","handlingStrategy":"validation","validationCode":"const STYLES = ['plastic', 'flat', 'flat-square', 'for-the-badge', 'social']\nif ('style' in badge && !STYLES.includes(badge.style)) {\n  badge.style = 'flat'\n}\nconst svg = makeBadge(badge)","typeGuard":"/** @returns {v is 'plastic'|'flat'|'flat-square'|'for-the-badge'|'social'} */\nfunction isValidStyle(v) {\n  return ['plastic', 'flat', 'flat-square', 'for-the-badge', 'social'].includes(v)\n}","tryCatchPattern":"try {\n  return makeBadge(badge)\n} catch (e) {\n  if (e instanceof ValidationError && e.message.startsWith('Field `style`')) {\n    return makeBadge({ ...badge, style: 'flat' })\n  }\n  throw e\n}","preventionTips":["Keep style strings in a constant/enum and never free-typing them","Whitelist user-supplied styles with a fallback to 'flat'","Copy exact kebab-case names from the library README"],"tags":["validation","enum-value","invalid-option"],"backgroundTag":"invalid-enum-value","analyzedSha":"766fd8bc89a90b8534dc573ab72dec30215ab1ec","analyzedAt":"2026-08-30T01:40:27.499Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}