{"record":{"id":"afe1711b46c4adc9","repo":"kataras/iris","slug":"parameter-is-not-alphabetical","errorCode":null,"errorMessage":"parameter is not alphabetical","messagePattern":"parameter is not alphabetical","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"macro/macros.go","lineNumber":379,"sourceCode":"\t\t\t\treturn !(paramValue < min || paramValue > max)\n\t\t\t}\n\t\t})\n\n\t// Bool or boolean as bool type\n\t// a string which is \"1\" or \"t\" or \"T\" or \"TRUE\" or \"true\" or \"True\"\n\t// or \"0\" or \"f\" or \"F\" or \"FALSE\" or \"false\" or \"False\".\n\tBool = NewMacro(\"bool\", \"boolean\", false, false, false, func(paramValue string) (any, bool) {\n\t\t// a simple if statement is faster than regex ^(true|false|True|False|t|0|f|FALSE|TRUE)$\n\t\t// in this case.\n\t\tv, err := strconv.ParseBool(paramValue)\n\t\tif err != nil {\n\t\t\treturn err, false\n\t\t}\n\t\treturn v, true\n\t})\n\n\t// ErrParamNotAlphabetical is fired when the parameter value is not an alphabetical text.\n\tErrParamNotAlphabetical = errors.New(\"parameter is not alphabetical\")\n\talphabeticalEval        = MustRegexp(\"^[a-zA-Z ]+$\")\n\t// Alphabetical letter type\n\t// letters only (upper or lowercase)\n\tAlphabetical = NewMacro(\"alphabetical\", \"\", \"\", false, false, func(paramValue string) (any, bool) {\n\t\tif !alphabeticalEval(paramValue) {\n\t\t\treturn fmt.Errorf(\"%s: %w\", paramValue, ErrParamNotAlphabetical), false\n\t\t}\n\t\treturn paramValue, true\n\t})\n\n\t// ErrParamNotFile is fired when the parameter value is not a form of a file.\n\tErrParamNotFile = errors.New(\"parameter is not a file\")\n\tfileEval        = MustRegexp(\"^[a-zA-Z0-9_.-]*$\")\n\t// File type\n\t// letters (upper or lowercase)\n\t// numbers (0-9)\n\t// underscore (_)\n\t// dash (-)","sourceCodeStart":361,"sourceCodeEnd":397,"githubUrl":"https://github.com/kataras/iris/blob/7bedaf55a0b64bbb2248a5845a2c60d81a30996a/macro/macros.go#L361-L397","documentation":"ErrParamNotAlphabetical is a sentinel error fired when a path parameter evaluated by the 'alphabetical' macro contains anything other than upper/lowercase letters or spaces (regexp ^[a-zA-Z ]+$). It is wrapped with the offending value via fmt.Errorf(\"%s: %w\", ...), so the actual failing text precedes it in the message.","triggerScenarios":"Route registered with {name:alphabetical} (or Alphabetical macro used in macros) and a request path contains digits, punctuation or unicode letters, e.g. '/users/renée' or '/users/john-1'.","commonSituations":"URLs containing hyphens (common in slugs), accents/unicode names, or numbers reach an alphabetical-only route; typical with usernames, city names or search terms in the path.","solutions":["Remove the offending characters client-side or encode/normalize the value.","Relax the macro: use {name:string} (any text) or a custom regexp macro like {slug:[a-zA-Z-]+}.","Add a separate route with a broader macro for the values you need to accept."],"exampleFix":"// before\napp.Get(\"/cities/{name:alphabetical}\", h) // rejects 'new-york'\n\n// after\napp.Get(\"/cities/{name:regexp(^[a-zA-Z -]+$)}\", h) // allows dashes","handlingStrategy":"validation","validationCode":"const isAlpha = (s: string) => /^[a-zA-Z ]+$/.test(s);\nconst url = isAlpha(name) ? `/users/${encodeURIComponent(name)}` : \"/users\";","typeGuard":"function isAlphabetical(v: string): boolean {\n  return /^[a-zA-Z ]+$/.test(v);\n}","tryCatchPattern":null,"preventionTips":["Sanitize/normalize user input before building URLs.","Avoid slugs with hyphens in alphabetical routes; use the regexp macro instead.","Document which characters each macro accepts."],"tags":["routing","validation","regex","iris"],"backgroundTag":"param-type-mismatch","analyzedSha":"7bedaf55a0b64bbb2248a5845a2c60d81a30996a","analyzedAt":"2026-08-30T20:38:16.250Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}