{"record":{"id":"f5986a0e015b87e0","repo":"remoteintech/remote-jobs","slug":"missing-required-field-field","errorCode":null,"errorMessage":"Missing required field: `${field}`","messagePattern":"Missing required field: `(.+?)`","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":".github/scripts/validate-companies.js","lineNumber":110,"sourceCode":"    content = readFileSync(filePath, \"utf-8\");\n  } catch (err) {\n    errors.push(`Could not read file: ${err.message}`);\n    return { errors, warnings };\n  }\n\n  // Parse frontmatter\n  const data = parseFrontmatter(content);\n  if (!data) {\n    errors.push(\n      \"Missing YAML frontmatter. The file must start with `---` followed by YAML fields and a closing `---`.\"\n    );\n    return { errors, warnings };\n  }\n\n  // Check required fields\n  for (const field of REQUIRED_FIELDS) {\n    if (!data[field] || (typeof data[field] === \"string\" && !data[field].trim())) {\n      errors.push(`Missing required field: \\`${field}\\``);\n    }\n  }\n\n  // Validate enum values (only if field exists)\n  if (data.region && !VALID_REGIONS.includes(data.region)) {\n    errors.push(\n      `Invalid \\`region\\`: \"${data.region}\". Must be one of: ${VALID_REGIONS.join(\", \")}`\n    );\n  }\n\n  if (data.remote_policy && !VALID_REMOTE_POLICIES.includes(data.remote_policy)) {\n    errors.push(\n      `Invalid \\`remote_policy\\`: \"${data.remote_policy}\". Must be one of: ${VALID_REMOTE_POLICIES.join(\", \")}`\n    );\n  }\n\n  if (data.company_size && !VALID_COMPANY_SIZES.includes(data.company_size)) {\n    errors.push(","sourceCodeStart":92,"sourceCodeEnd":128,"githubUrl":"https://github.com/remoteintech/remote-jobs/blob/b1dd8deb1945e5ff58f9e9c35e318f53c8871930/.github/scripts/validate-companies.js#L92-L128","documentation":"Loop at lines 108-112 over REQUIRED_FIELDS = [title, slug, website, region, remote_policy, company_size]. A field is 'missing' when it is falsy OR a string that trims to empty. Each missing field emits its own error line naming the offending key, so a single file can produce several.","triggerScenarios":"A required key is omitted entirely; the key is present but empty (`title:`); the value is whitespace-only; the key is misspelled (e.g. `remote-policy` with a hyphen instead of underscore, or camelCase `companySize`).","commonSituations":"Contributor copies a partial template; YAML key typo from a non-native snake_case user; a field was accidentally commented out; merge tool dropped a line.","solutions":["Add the named field with a non-empty value.","Verify the key uses snake_case exactly as listed in REQUIRED_FIELDS.","Re-run the validator and confirm the field's error line is gone."],"exampleFix":"// before\n---\ntitle: \"Acme\"\nslug: acme\n---\n// after\n---\ntitle: \"Acme\"\nslug: acme\nwebsite: https://acme.example\nregion: worldwide\nremote_policy: fully-remote\ncompany_size: small\n---","handlingStrategy":"validation","validationCode":"const REQUIRED_FIELDS = ['title','slug','website','region','remote_policy','company_size'];\nfunction missingFields(data) {\n  return REQUIRED_FIELDS.filter(f => !data[f] || (typeof data[f] === 'string' && !data[f].trim()));\n}","typeGuard":"function hasAllRequiredFields(data) {\n  return REQUIRED_FIELDS.every(f => data[f] && (!(typeof data[f] === 'string') || data[f].trim()));\n}","tryCatchPattern":null,"preventionTips":["Provide a complete company template in CONTRIBUTING.md with every required key.","Run a YAML schema validator in your editor on save.","Use snake_case exactly — never camelCase or kebab-case for these keys (except slug value)."],"tags":["yaml","frontmatter","required-fields","schema"],"backgroundTag":null,"analyzedSha":"b1dd8deb1945e5ff58f9e9c35e318f53c8871930","analyzedAt":"2026-08-13T04:09:00.804Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}