Skip to content

Configuration

whereAlphaNumeric()

whereAlphaNumeric() — returns struct

Available in: mapper Category: Routing

Constrain a route variable to only match alphanumeric characters (a-zA-Z0-9). Similar to Laravel’s whereAlphaNumeric().

NameTypeRequiredDefaultDescription
variableNamestringyes—The route variable name to constrain. Can also be a comma-delimited list.
<cfscript>

mapper()
    // 1. Constrain a single route variable to alphanumeric characters only
    .get(name="profile", pattern="profiles/[username]", to="profiles##show")
    .whereAlphaNumeric("username")

    // 2. Constrain multiple variables to alphanumeric in one call (comma-delimited list)
    .get(name="teamMember", pattern="teams/[teamCode]/members/[memberCode]", to="teams##member")
    .whereAlphaNumeric("teamCode,memberCode")

    // 3. Chain whereAlphaNumeric with a resources block to restrict the key variable
    .resources(name="products")
    .whereAlphaNumeric("key")
.end();

</cfscript>