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)
| 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. |
| 319 | fn 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 | /// |
no test coverage detected