Skip to main content

Validation Logic

Thred validates entity_type based on the business’s country:
  • Restricted countries (GB, DE, NL, ES, BE): Must use predefined business entity type codes
  • All other countries: Accept any string value for entity_type

Business Entity Types by Country

For these countries, the API will reject requests with invalid business entity types (HTTP 400).
Valid business entity types:
CodeDescription
limitedLtd (Private Limited Company)
sole_traderSole Trader
llpLimited Liability Partnership
partnershipPartnership
plcPublic Limited Company
Example:
{
  "entity_type": "limited",
  "country": "GB",
  "legal_name": "Acme Ltd"
}

Validation Behavior

Cross-Field Validation

The API validates entity_type against country in both create and update operations: Create Business:
POST /v1/platform/businesses/
{
  "entity_type": "gmbh",
  "country": "GB"  # ❌ FAILS - German type in UK
}
Update Business:
PATCH /v1/platform/businesses/{id}/
{
  "entity_type": "limited"  # Validates against business's existing country
}

Error Response

Invalid business entity types return HTTP 400 with details:
{
  "error_code": "validation_error",
  "detail": "Invalid entity_type 'gmbh' for country GB. Valid options: limited (Ltd (Private Limited Company)), sole_trader (Sole Trader), llp (Limited Liability Partnership (LLP)), partnership (Partnership), plc (Public Limited Company (PLC))"
}

Edge Cases

The entity_type field is optional (blank=True). Omitting it or passing an empty string is valid for all countries.
{
  "legal_name": "My Business",
  "country": "GB",
  "entity_type": ""  // ✅ Valid
}
Business entity type codes are case-insensitive. The API automatically normalizes them to lowercase:
  • "limited" → stored as "limited"
  • "Limited" → stored as "limited"
  • "LIMITED" → stored as "limited"
  • "GMBH" → stored as "gmbh"
Recommendation: Use lowercase for consistency, but any case will work.
When updating a business’s country, the existing entity_type is validated against the new country:
# Business created with entity_type="limited", country="GB"
PATCH /v1/platform/businesses/{id}/
{
  "country": "DE"  # ❌ FAILS - "limited" is not valid for DE
}
To change country, update both fields together with a valid business entity type for the target country.