Validate the view name.
(&self)
| 462 | |
| 463 | /// Validate the view name. |
| 464 | fn validate_view_name(&self) -> CliResult<()> { |
| 465 | let name = &self.view; |
| 466 | |
| 467 | if name.is_empty() { |
| 468 | return Err(CliError::InvalidArgument { |
| 469 | message: "View name cannot be empty".to_string(), |
| 470 | }); |
| 471 | } |
| 472 | |
| 473 | if name.contains('/') || name.contains('\\') { |
| 474 | return Err(CliError::InvalidArgument { |
| 475 | message: "View name cannot contain path separators".to_string(), |
| 476 | }); |
| 477 | } |
| 478 | |
| 479 | if name.starts_with('.') { |
| 480 | return Err(CliError::InvalidArgument { |
| 481 | message: "View name cannot start with a dot".to_string(), |
| 482 | }); |
| 483 | } |
| 484 | |
| 485 | if name.contains(char::is_whitespace) { |
| 486 | return Err(CliError::InvalidArgument { |
| 487 | message: "View name cannot contain whitespace".to_string(), |
| 488 | }); |
| 489 | } |
| 490 | |
| 491 | Ok(()) |
| 492 | } |
| 493 | } |
| 494 | |
| 495 | impl Default for Init { |