validateDirectoryExists static method
Validates that a directory exists and is accessible.
Parameters:
path: Directory path to validatename: Human-readable name for error messagescreateCommand: Suggested command to create the directory
Returns: ValidationResult indicating success or failure
Implementation
static ValidationResult<String> validateDirectoryExists(
String path,
String name,
String createCommand,
) {
if (!exists(path)) {
return ValidationResult.error(
'$name does not exist',
suggestion: 'Create the $name first or check the path',
examples: [createCommand, 'ls ${dirname(path)}/'],
);
}
return ValidationResult.success(path);
}