Skip to main content

env_name_charset_pattern

Function env_name_charset_pattern 

Source
pub const fn env_name_charset_pattern() -> &'static str
Expand description

Returns the environment-variable-name identifier charset as an anchored, JavaScript RegExp-compatible pattern source.

Matches validate_env_name’s charset rule: first character [A-Za-z_], subsequent characters [A-Za-z0-9_]*. Exposed so downstream consumers that must mirror this exact rule outside this function — currently, the generated TypeScript runtime bridge (crates/mcp-codegen/templates/progressive/runtime-bridge.ts.hbs) — can render their copy directly from this constant at code-generation time instead of hand-copying it. Closes the #467 gap where the bridge’s validateEnvName had no charset check at all and relied entirely on String.prototype.toUpperCase()’s incidental Unicode case folding to catch a forbidden-name confusable.

§Examples

use mcp_execution_core::env_name_charset_pattern;

assert_eq!(env_name_charset_pattern(), "^[A-Za-z_][A-Za-z0-9_]*$");