# verifyInstance method

1. @protected

Object? verifyInstance(

1. Object instance,
2. Class type,
3. String name,
4. DependencyDescriptor descriptor,

)

Verifies that a resolved instance matches the expected type and requirements.

This method performs type checking and nullability validation on resolved dependency instances to ensure they meet the dependency requirements.

`instance` the resolved instance to verify `type` the expected type of the dependency `name` the name of the pod being verified `descriptor` the dependency descriptor

Returns the verified instance

Throws:

- NoSuchPodDefinitionException if instance is NullablePod and dependency is required
- PodNotOfRequiredTypeException if instance type doesn't match expected type

## Implementation

    @protected
    Object? verifyInstance(Object instance, Class type, String name, DependencyDescriptor descriptor) {
      if (instance is NullablePod) {
        if (isRequired(descriptor)) {
          throw NoSuchPodDefinitionException.byTypeWithMessage(
            type,
            "No pod definition found for required type '${type.getQualifiedName()}'. "
            "Ensure that a pod of this type is registered in the factory or provided by configuration."
          );
        }

        return null;
      }

      if (!type.isInstance(instance)) {
        throw PodNotOfRequiredTypeException(name: name, requiredType: type, actualType: instance.getClass());
      }

      return instance;
    }