Validate a non-empty driver mount source.
(source: &str, field: &str)
| 34 | |
| 35 | /// Validate a non-empty driver mount source. |
| 36 | pub fn validate_mount_source(source: &str, field: &str) -> Result<(), String> { |
| 37 | if source.is_empty() { |
| 38 | return Err(format!("{field} must not be empty")); |
| 39 | } |
| 40 | if source != source.trim() { |
| 41 | return Err(format!("{field} must not contain surrounding whitespace")); |
| 42 | } |
| 43 | if source.as_bytes().contains(&0) { |
| 44 | return Err(format!("{field} must not contain NUL bytes")); |
| 45 | } |
| 46 | Ok(()) |
| 47 | } |
| 48 | |
| 49 | /// Validate a bind mount source as an absolute host path. |
| 50 | pub fn validate_absolute_mount_source(source: &str, field: &str) -> Result<(), String> { |
no test coverage detected