Top 30 Validation Interview Questions and Answers
30 multiple-choice questions on Validation, drawn from 30 bites out of the 56 tagged Validation on Tezvyn. Answer them here or read straight down. Every question carries the correct option, why it is correct, and a link to the bite it came from.
30 questions. Pick an answer, or open “Show the answer” to read it.
Answers are graded in your browser. Nothing is saved, and no XP or streak is earned here. The app keeps score.
Question 1 of 30
What mechanism triggers FastAPI to automatically validate and parse an incoming JSON request body against a schema?
Show the answer
Answer: b · Using a Pydantic model as the type hint for a route parameter
FastAPI inspects function signature type hints at runtime, so using a Pydantic model as a parameter type hint automatically triggers request parsing and validation. Manually calling json.loads inside the route is a red flag that ignores this declarative mechanism, and response_model governs response serialization, not request validation.
Read the full bite: How does FastAPI leverage Pydantic for request validation and serialization?
Question 2 of 30
What technical choice best serves an MVP whose goal is to validate market fit quickly?
Show the answer
Answer: d · Build only the core value path, instrument it for learning, and fake or outsource the rest
An MVP optimizes for validated learning, so you build the minimum core path, measure it, and use manual or off-the-shelf shortcuts elsewhere. Premature scaling, full feature sets, and polish all spend engineering on unvalidated assumptions.
Read the full bite: Technical principles for building a learning-focused MVP
Question 3 of 30
A FastAPI endpoint declares a path parameter as item_id: int. A request arrives for /items/abc, which cannot be coerced to an integer. What happens?
Show the answer
Answer: a · FastAPI returns an automatic 422 error describing the invalid value, and the endpoint function body never executes
FastAPI validates the coerced type before your function runs, so an uncoercible value short circuits into an automatic 422 with no handler code executing. Python itself does nothing with the int annotation at runtime, which is why expecting a TypeError or manual parsing misses the point of the hint.
Read the full bite: How FastAPI uses type hints for validation
Question 4 of 30
A client sends GET /items?limit=foo to an endpoint with parameter limit: int. What is FastAPI's default response?
Show the answer
Answer: a · HTTP 422 Unprocessable Entity with a JSON body whose detail array contains objects with loc, msg, and type fields
FastAPI relies on Pydantic to automatically validate query parameters and returns a 422 Unprocessable Entity with a JSON detail array of objects containing loc, msg, and type fields. Option B is tempting because the status code is correct, but the body structure is actually a detailed array rather than a single string.
Read the full bite: FastAPI non-integer query param default behavior
Question 5 of 30
Which method correctly enables automatic JSON body validation in a FastAPI route?
Show the answer
Answer: a · Subclass BaseModel and declare it as the type of a path operation function parameter
FastAPI inspects path operation parameter type annotations to automatically parse and validate incoming JSON against a Pydantic BaseModel. Manually calling request.json() bypasses this automatic pipeline, and response_model only defines the outgoing response schema rather than request validation.
Read the full bite: How do you define a Pydantic model for FastAPI request body validation?
Question 6 of 30
When a FastAPI endpoint receives JSON with extra fields not defined in the Pydantic model, what occurs by default?
Show the answer
Answer: d · Pydantic silently drops the extra fields and the request succeeds
By default Pydantic ignores extra fields, silently dropping them so the model instantiates and the request succeeds. Option C is wrong because that strict 422 behavior only happens when you explicitly configure extra to forbid in model_config.
Read the full bite: How does Pydantic handle extra JSON fields, and how to configure it?
Question 7 of 30
What is the key difference between a Pydantic field defined as name: str = 'guest' and one defined as name: Optional[str] = None?
Show the answer
Answer: d · The first rejects None while the second accepts it, but both may be omitted from input.
Both fields have defaults so neither is required, yet str = 'guest' rejects None while Optional[str] = None accepts it. Distractor A is tempting because Optional sounds optional, but requiredness is determined solely by the presence or absence of a default.
Read the full bite: What is the difference between a Pydantic default and Optional field?
Question 8 of 30
In Pydantic V2, how should you enforce a positive price and a regex-formatted SKU without writing custom validators?
Show the answer
Answer: b · Set price: float = Field(gt=0) and sku: str = Field(pattern=r'^ITEM-\d{5}$') on standard types
Field's built-in gt and pattern parameters enforce constraints natively without extra code, while @field_validator adds unnecessary boilerplate and ignores Pydantic V2's native capabilities.
Question 9 of 30
A product team observes a high rate of user churn and wants to understand the underlying reasons. Which research approach is most suitable for this initial phase?
Show the answer
Answer: b · Performing open-ended interviews with churned users to uncover their pain points and unmet needs.
Option B, performing open-ended interviews, is a generative research method designed to uncover latent needs and pain points, which is ideal for understanding the underlying reasons for churn. Options A, B, and D are evaluative methods, better suited for testing specific solutions or measuring existing states rather than defining the root problem.
Read the full bite: Generative vs. Evaluative Research: Define Problems vs. Judge Solutions
Question 10 of 30
You are writing a Pydantic v2 model with a name field that must be at least 3 characters. Which implementation is correct?
Show the answer
Answer: c · Use @field_validator('name') on a classmethod that raises ValueError and returns the value.
Pydantic v2 requires single-field validators to use @field_validator on a classmethod, raise ValueError on failure, and return the value so processing continues. Option B is tempting but wrong because omitting the return breaks the model lifecycle, and D uses the deprecated v1 pattern.
Read the full bite: Implement a custom validator for a single Pydantic model field
Question 11 of 30
What is the most reliable method for confirming an email address is both deliverable and actually controlled by a user?
Show the answer
Answer: d · Sending a verification email with a unique link for the user to click.
Sending a verification email is the only method that confirms both deliverability and user control. A complex regex is a common but flawed approach, as it can reject valid emails and cannot prove ownership.
Read the full bite: What validation checks would you implement for an email field?
Question 12 of 30
Which validation method provides the most definitive proof that a user-submitted email address is both valid and owned by the user?
Show the answer
Answer: a · Sending a verification email with a unique link that the user must click to confirm.
The card states that the "ultimate validation is an asynchronous confirmation loop" where the user clicks a unique link, providing "final proof of validity" and ownership. While MX record lookups confirm domain deliverability, they don't verify the specific inbox or user ownership, and complex regex is explicitly discouraged as impractical.
Read the full bite: How would you validate user-submitted email addresses at ingestion?
Question 13 of 30
When a parameter validated by FastAPI's Query or Path objects fails its defined constraints, what is the immediate outcome?
Show the answer
Answer: b · FastAPI stops request processing and returns a 422 Unprocessable Entity error to the client.
The card states that if validation fails, FastAPI immediately stops processing and returns a 422 Unprocessable Entity error. This prevents invalid data from reaching your function and provides clear feedback to the client, unlike the other options which describe different error handling or value manipulation.
Read the full bite: FastAPI: Validate Parameters with Query and Path
Question 14 of 30
You define a User model inheriting from BaseModel with name: str and age: int. What missing step lets FastAPI automatically validate an incoming JSON request body against it?
Show the answer
Answer: d · Type-hint a path operation parameter with User, e.g., async def create_user(user: User)
FastAPI treats a parameter type-hinted with a BaseModel subclass as the request body and validates it automatically. Option B is tempting but wrong because parsing the body manually with request.json() skips Pydantic validation and prevents OpenAPI documentation generation.
Read the full bite: How do you define a Pydantic model and use it in FastAPI?
Question 15 of 30
How does a self-registering Field pattern keep the Form decoupled from the specific fields used inside it?
Show the answer
Answer: b · Fields register themselves by name into shared context, so the Form never enumerates them
Self-registration lets the Form coordinate validation and submission over whatever fields registered, with no hardcoded list. Enumerating fields or centralizing all rules in the Form recreates the coupling you want to avoid.
Read the full bite: Decoupling Form state from its Field components
Question 16 of 30
In a production time-series forecasting pipeline using rolling-origin validation, which approach correctly prevents future leakage?
Show the answer
Answer: a · Use backward-looking windows ending at t minus one and fit scalers exclusively on each training fold before transforming the matching validation fold
Backward-looking windows ending at t minus one ensure no future data enters features, and fitting preprocessing per training fold stops global statistics from leaking into validation. Option D is tempting because global scaling is standard in non-temporal ML, yet it embeds future information into every historical row before any split occurs.
Read the full bite: How do you prevent future leakage in time-series preprocessing?
Question 17 of 30
In Flutter, when will a TextFormField inside a Form display the error text returned by its validator?
Show the answer
Answer: b · Only after formKey.currentState.validate() is explicitly called
Calling validate() on the FormState walks the form tree and executes each registered validator, rendering any returned string as inline error text. A is tempting because beginners often assume onChanged triggers validation, but keystrokes alone do not run the validator.
Read the full bite: Explain the validator property in TextFormField and what triggers error display
Question 18 of 30
When implementing a login form with Flutter's Form widget, which statement accurately describes the validation flow?
Show the answer
Answer: d · Wrap TextFormField widgets in a Form assigned a GlobalKey<FormState>, then call key.currentState.validate() in the submit handler to aggregate all validator results.
Option D is correct because GlobalKey<FormState> exposes the validate() method that aggregates every descendant TextFormField validator and rebuilds error labels, and it is meant to be called on submission. Option C is tempting because it names the right widgets and method, but GlobalKey<Form> is the wrong generic type and does not provide access to validate().
Read the full bite: Build and validate a login form with Form and GlobalKey
Question 19 of 30
When building real-time email validation in React, which state strategy best follows declarative, state-driven patterns?
Show the answer
Answer: d · Store the raw input in useState, use a single status enum such as typing or error, and derive validation during render.
The correct approach uses a single status enum and derives validation during render, avoiding redundant state. Option A is wrong because multiple boolean flags require manual synchronization and invite stale state bugs.
Read the full bite: How would you implement real-time client-side validation in React?
Question 20 of 30
How does React Hook Form primarily avoid re-rendering an entire form on every keystroke, compared to manual useState management?
Show the answer
Answer: d · It registers inputs via refs and treats them as uncontrolled, reading values only when needed.
React Hook Form attaches refs to inputs and keeps them uncontrolled so React does not render on every keystroke; values are read at validation or submission. The first option describes Formik's context-and-subscription strategy, which is a common point of confusion between the two libraries.
Read the full bite: Advantages of dedicated React form libraries over manual state
Question 21 of 30
Which pattern best prevents data loss and supports accurate per-step validation when users move non-linearly through a React wizard?
Show the answer
Answer: c · Maintain a single root form instance, validate only the current step's Zod slice before advancing, and hydrate defaultValues from localStorage on mount.
A single root form with per-step Zod slices ensures only touched fields are validated before navigation, while localStorage hydration prevents data loss on refresh. Option A is tempting because it correctly centralizes the form, but validating the entire schema prematurely surfaces errors for untouched future fields and skipping persistence leaves users vulnerable to data loss.
Read the full bite: Design a multi-step wizard form pattern in React
Question 22 of 30
What core limitation of TypeScript does Zod primarily address in an application?
Show the answer
Answer: a · TypeScript's type system being entirely erased at runtime.
Zod's primary purpose, as detailed in the card, is to provide runtime validation because "TypeScript types are erased at compile time," making applications vulnerable to untrusted data. Option D describes a benefit Zod enables in certain ecosystems, not the fundamental limitation of TypeScript's type system that Zod directly addresses.
Question 23 of 30
Which practice best establishes an auditable evidence chain when tracing qualitative data to journey map stages?
Show the answer
Answer: a · Inviting engineers to review a structured repository that indexes raw quotes and observations against specific stages and pain points
The correct answer reflects the card's emphasis on a traceability matrix and collaborative verification with technical stakeholders. Option C is tempting because quantitative metrics identify where problems occur, but the card explicitly warns that drop-off rates and NPS scores alone cannot validate qualitative stage meanings or provide inspectable customer evidence.
Read the full bite: How do you trace data points to journey map stages?
Question 24 of 30
In Svelte 5, how do you bind an input to reactive state and log its validity after every keystroke?
Show the answer
Answer: c · Use $state for the input and run validation logic inside an $effect that reads it.
B is correct because $state creates tracked reactive state, and an $effect automatically re-runs whenever state it reads changes. C is tempting but wrong because writing to the same $state variable inside an effect that reads it creates an infinite loop.
Read the full bite: Bind an input to a variable and validate with reactivity
Question 25 of 30
When building a reusable Svelte validation action, which approach satisfies the lifecycle contract and keeps the logic portable?
Show the answer
Answer: a · Accept the DOM node, attach listeners, toggle classes or ARIA directly, and return update and destroy methods.
A Svelte action receives the mounted node and must return an object with update and destroy to handle parameter changes and automatic cleanup. Distractor A is tempting because stores are idiomatic in Svelte, but actions should perform imperative DOM manipulation directly rather than coupling to the component's reactive state graph.
Read the full bite: How would you build a reusable Svelte validation action?
Question 26 of 30
When building a dynamic Vue form where users can add, remove, and reorder rows, which pattern best preserves reactivity, component state, and clean validation logic?
Show the answer
Answer: b · Use a flat reactive array where each row has a unique id, bind :key to row.id, render each row in its own component, and keep validation rules in a separate schema keyed by field name.
Option B is correct because stable row IDs as :key let Vue track insertions and deletions accurately, row components encapsulate mutations and local state, and a separate schema keeps validation metadata out of the business model. Option A is tempting because it also uses unique IDs, but mutating the array by index breaks reactivity detection and embedding validation rules inside row data couples schema to state.
Read the full bite: How do you structure components and state for a dynamic Vue form?
Question 27 of 30
When building a multi-step Svelte wizard with stores, which approach best persists state across unmounted steps and enforces validation before navigation?
Show the answer
Answer: d · Centralize all wizard state in a single store keyed by step, compute validity via derived stores, and call an imperative validateStep guard before incrementing the active step index.
A centralized store keyed by step ensures data survives unmounting, while derived validity and imperative guards keep progression declarative yet explicitly controlled. Option A is tempting because it uses a single store and derived state, but reactive auto-advance bypasses pre-navigation guards and can advance before async validation finishes.
Read the full bite: How would you architect a multi-step Svelte wizard with Stores?
Question 28 of 30
Which validation scenario would typically require a custom validator rather than a built-in Angular validator?
Show the answer
Answer: a · Validating that a password input matches its 'Confirm Password' counterpart.
The card explicitly states that built-in validators are not suited for complex, multi-field validation like comparing two password fields, which would require a custom validator. The other options are all handled by specific built-in validators (minLength, requiredTrue, and email, respectively).
Question 29 of 30
When _formKey.currentState!.validate() is invoked on a Flutter Form, what is its immediate effect?
Show the answer
Answer: b · It executes the validator function for every descendant FormField.
The card explicitly states that calling validate() "triggers the validator on every field." Option C describes the action of the save() method, not validate().
Read the full bite: Flutter's Form Widget: Grouping and Validating Input
Question 30 of 30
What is the primary advantage of using VeeValidate for form development in Vue?
Show the answer
Answer: a · It significantly reduces boilerplate code by managing form values, validation, and submission lifecycle.
VeeValidate's core purpose is to manage the entire lifecycle of a Vue form, including values, validation, and submissions, specifically to eliminate repetitive boilerplate code. It is a dedicated state machine for forms, not a general application state manager, nor does it provide UI components or automate backend API creation.
Read the full bite: VeeValidate: Vue Forms Without the Boilerplate
Could you explain these out loud?
That is what an interview actually tests. Tezvyn gives you questions like these with what the interviewer is really checking, the answer that lands, and the mistake that ends the conversation, in the four minutes before your next meeting.
The iPhone app is on the way
We are building it. Until it lands, nothing here is held back from you: every interview card, your saved cards, streaks and the job board all work in Safari, plus hundreds of free practice quizzes of thirty questions each. Sign in and it all carries over to the app the day it arrives.
Want it as an icon? Tap Share at the bottom of Safari, then Add to Home Screen. It opens full screen and the cards you have read stay available offline.