MCPcopy Create free account
hub / github.com/NVIDIA/OpenShell / validate_gcp_project_id

Function validate_gcp_project_id

crates/openshell-server/src/inference.rs:319–336  ·  view source on GitHub ↗

Validate a GCP project ID against the documented format. GCP project IDs must be 6–30 characters, start with a lowercase letter, contain only lowercase letters, digits, and hyphens, and not end with a hyphen.

(value: &str)

Source from the content-addressed store, hash-verified

317/// GCP project IDs must be 6–30 characters, start with a lowercase letter,
318/// contain only lowercase letters, digits, and hyphens, and not end with a hyphen.
319fn validate_gcp_project_id(value: &str) -> Result<(), Status> {
320 let valid = value.len() >= 6
321 && value.len() <= 30
322 && value.starts_with(|c: char| c.is_ascii_lowercase())
323 && !value.ends_with('-')
324 && value
325 .chars()
326 .all(|c| c.is_ascii_lowercase() || c.is_ascii_digit() || c == '-');
327 if valid {
328 Ok(())
329 } else {
330 Err(Status::invalid_argument(format!(
331 "VERTEX_AI_PROJECT_ID has invalid format: {value:?}. \
332 GCP project IDs must be 6-30 characters, start with a lowercase letter, \
333 contain only lowercase letters, digits, and hyphens, and not end with a hyphen."
334 )))
335 }
336}
337
338/// Validate a GCP region/location value.
339///

Callers 1

resolve_vertex_ai_routeFunction · 0.85

Calls 1

lenMethod · 0.80

Tested by

no test coverage detected