koala73/worldmonitor · error · ValidationError
Name is required
Error message
Name is required
What it means
Required-field validation on the contact form (submit-contact.ts:161): name must be present AND name.trim().length > 0. Empty string, undefined, or whitespace-only fails with a ValidationError on field 'name'. Values are truncated to MAX_FIELD=500 only AFTER this check, so any non-blank value 1-500+ chars passes.
Source
Thrown at server/worldmonitor/leads/v1/submit-contact.ts:162
logPrefix: '[contact]',
});
if (!turnstileOk) {
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', '');
}View on GitHub (pinned to a96956387a)
Solutions
- Mark the name input required and validate non-blank after trim client-side
- Initialize form state with '' and check name.trim() before enabling submit
- On the server error, map violations[].field === 'name' back to the input for display
Example fix
// before
await submitContact({ name: ' ', ... }); // whitespace-only -> ValidationError
// after
const name = rawName.trim();
if (!name) throw new Error('name required');
await submitContact({ name, ... }); Defensive patterns
Strategy: validation
Validate before calling
const name = rawName.trim();
if (!name) { showFieldError('name', 'Name is required'); return; }
await submitContact({ ...form, name }); 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 === 'name') showFieldError('name', v.description);
return;
}
throw e;
} Prevention
- Validate all required fields client-side after trim() before enabling submit
- Run the full field battery at once so users fix everything in one pass
- Bind the input to initialized ('') state so undefined never ships
When it happens
Trigger: Submitting the form without typing a name; a whitespace-only value (user hit space); the name input not bound to state so undefined ships; a test payload omitting the field entirely.
Common situations: Forms where the name field is optional in the UI but required server-side; state initialization bugs leaving name undefined; paste of an invisible/zero-width character passes trim() only if non-whitespace — plain spaces are the usual culprit.
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
- Company is required
- callbackUrl is required
- Invalid email address
- Invalid email
- Valid phone number is required
AI-assisted analysis of koala73/worldmonitor@a96956387a (2026-08-21).
Data as JSON: /api/errors/9376b066f3a64228.
Report an issue: GitHub.