Task Description
Write a Python function that validates US phone numbers and converts them to E.164 format. Requirements: - Accept a raw string input - Return the number in E.164 format (+1XXXXXXXXXX) if valid - Return None for missing or empty strings - Raise ValueError with a clear error message for malformed numbers - Handle these common formats: (555) 867-5309, 555-867-5309, 5558675309 - Process only the 10-digit core number (no extensions) Deliverables: - A single Python function with clear docstring - 3 unit tests covering: valid input in different formats, empty/None input, and invalid input - All code should be production-ready with proper error messages Success criteria: - Function correctly normalizes all valid formats to E.164 - Handles edge cases (empty strings, None, extra whitespace) - Tests pass and demonstrate the function works as expected