(bucketName: string)
| 154 | * - Cannot contain "google" or close misspellings such as "g00gle". |
| 155 | */ |
| 156 | export function validateIcebergConfigBucketName(bucketName: string): void { |
| 157 | if (bucketName.length < 3 || bucketName.length > 63) { |
| 158 | throw new Error("Bucket name must be between 3 and 63 characters long."); |
| 159 | } |
| 160 | if (!/^[a-z0-9][a-z0-9-._]{1,220}[a-z0-9]$/.test(bucketName) || bucketName.includes("..")) { |
| 161 | throw new Error( |
| 162 | "Invalid bucket name. Must start and end with a letter or number, contain only lowercase letters, numbers, hyphens (-), underscores (_), and periods (.)." |
| 163 | ); |
| 164 | } |
| 165 | if (bucketName.startsWith("goog") || bucketName.includes("--")) { |
| 166 | throw new Error("Bucket name cannot start with 'goog' or contain '--'."); |
| 167 | } |
| 168 | if(bucketName.includes("google") || bucketName.includes("g00gle")) { |
| 169 | throw new Error("Bucket name cannot contain 'google' or close misspellings such as 'g00gle'."); |
| 170 | } |
| 171 | } |
| 172 | |
| 173 | /** |
| 174 | * Validates a string to ensure it is a valid table folder root for an Iceberg |
no test coverage detected