Skip to content

The fastest, litest AI Gateway. Rust core with Python SDK. Call 100+ LLM APIs in OpenAI (or native) format with cost tracking, guardrails, load balancing, and logging [Bedrock, Azure, OpenAI, Anthropic, OpenAI, VertexAI, vLLM, Nvidia NIM]

497 B
Raw Blame
use crate::{Error, ErrorDetail};

pub(crate) fn validated_region(region: String) -> Result<String, Error> {
    if !region.is_empty()
        && region
            .bytes()
            .all(|byte| byte.is_ascii_lowercase() || byte.is_ascii_digit() || byte == b'-')
    {
        return Ok(region);
    }
    Err(Error::InvalidRequest(ErrorDetail::InvalidValue {
        field: "aws_region_name",
        expected: "lowercase letters, digits, and hyphens",
        actual: region.into(),
    }))
}