The billingCountry field in companyProfiles is a free-form varchar. Without validation, invalid values (e.g., "United States", "usa") can be stored, breaking integrations with payment processors and compliance checks that expect strict ISO 3166-1 alpha-2 codes (e.g., "US", "GB", "NG").
Implementation Guidelines
Key Files: src/server/validations/ (whichever Zod schema handles company/profile updates).
- Install or import a list of valid ISO 3166-1 alpha-2 codes (use the
i18n-iso-countries package or a static constant array).
- In the Zod validation schema for
billingCountry, add:
billingCountry: z.string().length(2).toUpperCase().refine(isValidIsoAlpha2, {
message: "billingCountry must be a valid ISO 3166-1 alpha-2 code",
})
- Apply the same validation to
registeredCountry if it exists in the same schema.
Expectations
What done looks like: POSTing "billingCountry": "United States" returns a 400 validation error. POSTing "billingCountry": "US" passes. Existing tests for company profile creation/update are updated or added.
Discord for any questions: codeze_us
The
billingCountryfield incompanyProfilesis a free-form varchar. Without validation, invalid values (e.g.,"United States","usa") can be stored, breaking integrations with payment processors and compliance checks that expect strict ISO 3166-1 alpha-2 codes (e.g.,"US","GB","NG").Implementation Guidelines
Key Files:
src/server/validations/(whichever Zod schema handles company/profile updates).i18n-iso-countriespackage or a static constant array).billingCountry, add:registeredCountryif it exists in the same schema.Expectations
What done looks like: POSTing
"billingCountry": "United States"returns a 400 validation error. POSTing"billingCountry": "US"passes. Existing tests for company profile creation/update are updated or added.Discord for any questions: codeze_us