← Stackadapt Interview Insights

Stackadapt·Software Engineer·Technical Phone Screen·Intermediate

Intermediate
Jun 2026

Summary

Stackadapt software engineer interview had a coding portion where they gave you two domain classes from earlier in the session and asked you to write validators for both. The design angle made it more interesting than a typical leetcode grind.

Questions Asked (1)

Q1

Given two domain classes defined earlier in the interview, write a validation function for each that collects all field-level errors without short-circuiting, then explain how you'd structure the validation logic so both classes can share code.

Technical Trade-offsSystem DesignAlgorithms & Data Structures
Author's notes

The 'collect all errors, don't stop at the first one' part is what tripped me up initially.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by writing a simple validation function for each class that iterates over all fields and accumulates errors into a list, avoiding early returns. Then refactor by extracting common validation rules into reusable functions or a shared validator class, and show how each class can compose these rules while still handling class-specific logic.

Pro tip: Mention that you'd use a validation library or pattern like Specification or Strategy to make rules composable and testable, but keep the initial implementation simple to demonstrate core logic. Also, discuss how you'd handle cross-field validations and error message localization as a natural extension.

1. Clarify requirements and assumptions

Ask about the domain classes, validation rules, and expected error format. Confirm that all errors should be collected and that shared code is desired.

2. Implement per-class validation

For each class, write a function that checks each field against its rules, appends errors to a list, and returns the list without short-circuiting.

3. Identify common validation patterns

Extract shared rules (e.g., non-empty, length, format) into standalone functions or a validator object that can be reused across classes.

4. Design shared validation structure

Propose a composition-based approach: each class defines its fields and associated rules, and a generic validator applies them. Discuss trade-offs between inheritance and composition.

5. Discuss extensibility and testing

Explain how new rules can be added without modifying existing code, and how unit tests can cover both shared and class-specific validations.

Key Points to Mention

  • Collecting all errors vs. short-circuiting: use a list to accumulate errors and return after checking all fields.
  • Separation of concerns: validation logic should be separate from domain classes, possibly using a Validator interface or service.
  • Reusability: extract common validation rules into functions or classes that can be composed.
  • Composition over inheritance: prefer composing validators rather than deep inheritance hierarchies.
  • Error representation: use a structured error object (field, message, code) for consistency.
  • Testing: ensure both shared and class-specific validations are unit tested, including edge cases.

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.