validateDirectoryExists static method

ValidationResult<String> validateDirectoryExists(
  1. String path,
  2. String name,
  3. String createCommand
)

Validates that a directory exists and is accessible.

Parameters:

  • path: Directory path to validate
  • name: Human-readable name for error messages
  • createCommand: 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);
}