koala73/worldmonitor · error · ValidationError

Company is required

Error message

Company is required

What it means

Required-field validation on the contact form (submit-contact.ts:164): organization must be present AND organization.trim().length > 0, else a ValidationError on field 'organization' ('Company is required') is thrown. Checked after name, before phone — the handler reports one violation at a time in field order, so fixing name alone surfaces this next.

Source

Thrown at server/worldmonitor/leads/v1/submit-contact.ts:165

    throw new ApiError(403, 'Bot verification failed', '');
  }

  const { email, name, organization, phone, message, source } = req;

  if (!email || !EMAIL_RE.test(email)) {
    throw new ValidationError([{ field: 'email', description: 'Invalid email' }]);
  }

  const emailDomain = email.split('@')[1]?.toLowerCase();
  if (emailDomain && FREE_EMAIL_DOMAINS.has(emailDomain)) {
    throw new ApiError(422, 'Please use your work email address', '');
  }

  if (!name || name.trim().length === 0) {
    throw new ValidationError([{ field: 'name', description: 'Name is required' }]);
  }
  if (!organization || organization.trim().length === 0) {
    throw new ValidationError([{ field: 'organization', description: 'Company is required' }]);
  }
  if (!phone || !PHONE_RE.test(phone.trim())) {
    throw new ValidationError([{ field: 'phone', description: 'Valid phone number is required' }]);
  }

  const safeName = name.slice(0, MAX_FIELD);
  const safeOrg = organization.slice(0, MAX_FIELD);
  const safePhone = phone.trim().slice(0, 30);
  const safeMsg = message ? message.slice(0, MAX_MESSAGE) : undefined;
  const safeSource = source ? source.slice(0, 100) : 'enterprise-contact';

  const convexUrl = process.env.CONVEX_URL;
  if (!convexUrl) {
    throw new ApiError(503, 'Service unavailable', '');
  }

  const client = new ConvexHttpClient(convexUrl);
  try {

View on GitHub (pinned to a96956387a)

Solutions

  1. Make Company a required input and validate non-blank after trim
  2. Map your form's company/employer field explicitly to the organization key
  3. Batch client-side validation so name+organization+phone all report together instead of drip-feeding server errors

Example fix

// before
await submitContact({ name, organization: '', ... }); // -> "Company is required"

// after
const organization = rawOrg.trim();
if (!organization) throw new Error('company required');
await submitContact({ name, organization, ... });
Defensive patterns

Strategy: validation

Validate before calling

const organization = rawOrg.trim();
if (!organization) { showFieldError('organization', 'Company is required'); return; }
await submitContact({ ...form, organization });

Type guard

function isNonBlankString(v: unknown): v is string {
  return typeof v === 'string' && v.trim().length > 0;
}

Try / catch

try { await submitContact(form); }
catch (e) {
  if (isValidationError(e)) {
    for (const v of e.violations ?? []) if (v.field === 'organization') showFieldError('organization', v.description);
    return;
  }
  throw e;
}

Prevention

When it happens

Trigger: Omitting the organization field; whitespace-only company input; solo users leaving 'Company' blank because they are independent; a single 'Full name' field being mapped to name with nothing mapped to organization.

Common situations: Contact forms with optional-looking company fields; B2B forms where freelancers have no employer; frontend/state mapping bugs that drop the organization key during serialization.

Understand the failure class

Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.

Related errors


AI-assisted analysis of koala73/worldmonitor@a96956387a (2026-08-21). Data as JSON: /api/errors/742cd526b6234129. Report an issue: GitHub.