The core logic is dead simple, loop through records and check the fields.
Start by clarifying the definition of 'present' and 'non-empty' for each KYC field, considering data types and business rules. Then outline a robust algorithm that handles edge cases like whitespace, null, undefined, and type mismatches, and discuss trade-offs between strictness and practicality. Finally, emphasize the importance of validation and testing to ensure correctness.
Pro tip: Mention that in a real-world system like Stripe, you'd likely have a centralized validation utility to ensure consistency across services, and you'd log edge cases for monitoring and iterative improvement.
Ask clarifying questions to define what 'present' and 'non-empty' mean for each field, including handling of whitespace, null, undefined, empty strings, and type coercion.
Propose a function that iterates over the 6 fields, checking each against the defined criteria, and returns VERIFIED only if all pass.
Detail how to treat edge cases: trim whitespace, reject null/undefined, consider empty arrays/objects as empty, and decide on type-specific checks (e.g., numbers must be > 0).
Talk about strict vs. lenient validation, performance for large lists, and potential need for configuration or field-specific rules.
Mention writing unit tests for edge cases and using sample data to verify the logic before deployment.
AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.