Stripe·Software Engineer·Technical Phone Screen
- Given an object mapping country names to passport number patterns (where L = letter, D = digit, A = alphanumeric), build a minimal UI with a country selector, a passport number input, and a Validate button.
- Implement a validate(country, value) function that returns true only if the value exactly matches the selected country's pattern. How do you handle edge cases like empty input, leading/trailing whitespace, unexpected country keys, case sensitivity, extra characters, and partial matches?
- Wire the UI so that clicking Validate shows an inline error when the input is invalid, does nothing visible when valid, clears state when the country changes, and clears errors when the input changes.
- Write console-based tests covering valid and invalid passport numbers across multiple countries and edge cases.
- How would you improve this component's accessibility (labels, ARIA, focus management, error semantics, keyboard navigation, color contrast) and what would you change to make it production-ready (validation robustness, internationalization, performance, security, telemetry, and testing strategy)?
“Seemed straightforward at first.”