Validate the view name.
(&self)
| 437 | |
| 438 | /// Validate the view name. |
| 439 | fn validate_view_name(&self) -> CliResult<()> { |
| 440 | let name = &self.view; |
| 441 | |
| 442 | if name.is_empty() { |
| 443 | return Err(CliError::InvalidArgument { |
| 444 | message: "View name cannot be empty".to_string(), |
| 445 | }); |
| 446 | } |
| 447 | |
| 448 | if name.contains('/') || name.contains('\\') { |
| 449 | return Err(CliError::InvalidArgument { |
| 450 | message: "View name cannot contain path separators".to_string(), |
| 451 | }); |
| 452 | } |
| 453 | |
| 454 | if name.starts_with('.') { |
| 455 | return Err(CliError::InvalidArgument { |
| 456 | message: "View name cannot start with a dot".to_string(), |
| 457 | }); |
| 458 | } |
| 459 | |
| 460 | if name.contains(char::is_whitespace) { |
| 461 | return Err(CliError::InvalidArgument { |
| 462 | message: "View name cannot contain whitespace".to_string(), |
| 463 | }); |
| 464 | } |
| 465 | |
| 466 | Ok(()) |
| 467 | } |
| 468 | } |
| 469 | |
| 470 | impl Default for Init { |