resource-validation: Resource Validation System for Connector Objects
Description
This module provides a flexible validation system to verify that resources
required by connector objects exist and are accessible. The validation is
performed through S3 method dispatch, allowing each connector class to define
its own validation logic while providing a consistent interface.
Usage
validate_resource(x)
check_resource(self)
# S3 method for Connector
check_resource(self)
# S3 method for ConnectorFS
check_resource(self)
Arguments
x
Connector object to validate.
self
Connector object for method dispatch.
Architecture
The system is built around two main components:
validate_resource(): A dispatcher function that finds and
executes the appropriate S3 method based on the connector's class
check_resource(): A generic S3 method that defines the
validation interface for all connector types
Method Resolution
The validation process follows this hierarchy:
Attempt to find a class-specific method (e.g., check_resource.ConnectorFS)
If no specific method exists, fall back to the default check_resource.Connector
Execute the resolved method with appropriate error handling
Available S3 Methods
check_resource.Connector
Default method that performs no validation.
Serves as a safe fallback for connector classes without specific validation needs.
check_resource.ConnectorFS
Validates file system resources by checking
directory existence using fs::dir_exists(). Throws informative errors
for missing directories.
Implementation Guidelines
When implementing new connector classes with resource validation:
Define a method following the pattern check_resource.<YourClass>
Return NULL on successful validation
Use cli::cli_abort() for validation failures to provide consistent error formatting
Include call = rlang::caller_env() in error calls for proper error context
Error Handling
The validation system provides robust error handling:
Method resolution failures are handled gracefully with fallback to default
Validation errors include contextual information about the failing resource
Error messages use cli formatting for consistency across the package