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