Centralized CQL identifier sanitization.
All CQL identifiers (table names, column names, keyspace names, index names, etc.) MUST be validated through this module before being interpolated into CQL strings. This prevents CQL injection attacks.
Valid identifiers
CQL identifiers must start with a letter or underscore, followed by
alphanumeric characters or underscores. This matches the regex
~r/^[a-zA-Z_][a-zA-Z0-9_]*$/.
Usage
iex> AshScylla.Identifier.sanitize!("users")
"users"
iex> AshScylla.Identifier.sanitize!("my_table")
"my_table"
iex> AshScylla.Identifier.sanitize!("users; DROP TABLE users")
** (ArgumentError) Invalid CQL identifier: "users; DROP TABLE users"
Summary
Functions
Validates that the given value is a safe CQL identifier, raising on failure.
Validates that the given string is a safe CQL identifier.
Functions
Validates that the given value is a safe CQL identifier, raising on failure.
Accepts both atoms (common in Ash resource definitions) and strings. Atoms are converted to strings before validation.
Returns the sanitized string if valid, raises ArgumentError if not.
Validates that the given string is a safe CQL identifier.
Returns {:ok, name} if valid, or {:error, reason} if not.