← Questions

Merchant onboarding CSV validator

0
StripeCodingLast asked Oct 2026

Merchants submit their business details as rows of a simple CSV. Before a merchant can accept payments, every row must pass a set of checks. Write validate_records(data, forbidden_words, ignore_words) -> list[str].

Input

  • data: a list of strings. data[0] is a header with six comma-separated column names: business_name, legal_name, statement_descriptor, short_descriptor, url, product_description. The columns can appear in any order. Each later string is one merchant. You can assume fields contain no commas or quotes.
  • forbidden_words: words or multi-word phrases that may not appear in customer-facing fields.
  • ignore_words: filler words (for example the, inc, llc) that are skipped when comparing the name with the descriptor.

Output

One string per data row, in order: "VERIFIED", or "NOT VERIFIED: <reason>" for the first rule that fails.

Rules (checked in this order; trim fields, compare case-insensitively, and treat any non-alphanumeric character as a word separator)

  1. Every column is non-blank. Reason: missing <column>. A row with the wrong number of cells gets malformed row.
  2. statement_descriptor is 5–22 characters long, and short_descriptor is 2–10. Reason: <column> length.
  3. No forbidden word or phrase appears, as whole words, in business_name, statement_descriptor or short_descriptor. Reason: forbidden word in <column>.
  4. Remove ignore words from business_name and from statement_descriptor. At least half of the name's remaining distinct words must appear in the descriptor. If no words remain in the name, the rule fails. Reason: descriptor does not match business_name.

Example 1

forbidden_words = ["online store"]
ignore_words    = ["llc", "co"]
data = [
  "business_name,legal_name,statement_descriptor,short_descriptor,url,product_description",
  "Juniper Bakery,Juniper Bakery LLC,JUNIPER BAKERY,JUNIPER,juniper.example,Bread",
  "Best Online Store,Best LLC,BEST ONLINE STORE,BEST,best.example,Gadgets",
  "Juniper Bakery,Juniper Bakery LLC,JB,JUNIPER,juniper.example,Bread",
]

Output: ["VERIFIED", "NOT VERIFIED: forbidden word in business_name", "NOT VERIFIED: statement_descriptor length"].

Example 2

Northwind Trading Co with descriptor NORTHWIND PAYMENTS is verified: co is ignored, and 1 of the 2 remaining words matches, which is exactly half. Blue Harbor Fish Market with descriptor HARBOR GOODS fails rule 4, because only 1 of 4 words matches.

Expect follow-ups such as reporting every failed rule, handling quoted CSV fields, and making the rules configurable.

Reconstructed from the reported question; details may differ from what interviewers ask.

Write and test your solution herePython in your browser, the question's tests level by level, saved for you.Sign in to start coding