{"slug": "learn-schema-validation-with-a-tiny-github-issue-fields-project", "title": "Learn Schema Validation With a Tiny GitHub Issue Fields Project", "summary": "A developer created a beginner project using GitHub's new Issue fields to teach schema validation. The project validates structured issue metadata before an MCP client uses it, covering type and domain constraints. The tutorial emphasizes that validation is not authorization and highlights common beginner mistakes.", "body_md": "GitHub announced on July 2, 2026 that Issue fields are generally available, including integration with GitHub's MCP server.\n\nPrimary source: [GitHub Changelog, July 2, 2026](https://github.blog/changelog/2026-07-02-issue-fields-are-now-generally-available/).\n\nThat creates a useful beginner project: validate structured issue metadata before an MCP client—or any program—uses it. The schema below is invented for learning. It is not GitHub's API schema.\n\n``` js\n// schema.mjs\nexport const schema = {\n  priority: {\n    kind: \"singleSelect\",\n    required: true,\n    options: [\"P0\", \"P1\", \"P2\", \"P3\"]\n  },\n  estimate: { kind: \"number\", required: false, min: 0, max: 100 },\n  customerImpact: { kind: \"text\", required: false, maxLength: 120 }\n};\n```\n\nA schema describes both type and domain rules. `estimate`\n\nmust be a number, but it also has to fit the range this project accepts.\n\n``` js\n// validate.mjs\nimport { schema } from \"./schema.mjs\";\n\nexport function validate(input) {\n  const errors = [];\n  if (!input || Array.isArray(input) || typeof input !== \"object\") {\n    return [\"fields must be an object\"];\n  }\n\n  for (const [name, rule] of Object.entries(schema)) {\n    if (rule.required && !(name in input)) errors.push(`${name}: missing`);\n  }\n\n  for (const [name, value] of Object.entries(input)) {\n    const rule = schema[name];\n    if (!rule) { errors.push(`${name}: unknown field`); continue; }\n\n    if (rule.kind === \"singleSelect\" &&\n        (typeof value !== \"string\" || !rule.options.includes(value))) {\n      errors.push(`${name}: expected ${rule.options.join(\", \")}`);\n    }\n    if (rule.kind === \"number\" &&\n        (typeof value !== \"number\" || !Number.isFinite(value) ||\n         value < rule.min || value > rule.max)) {\n      errors.push(`${name}: expected ${rule.min}..${rule.max}`);\n    }\n    if (rule.kind === \"text\" &&\n        (typeof value !== \"string\" || value.length > rule.maxLength)) {\n      errors.push(`${name}: expected at most ${rule.maxLength} characters`);\n    }\n  }\n  return errors;\n}\n```\n\nTry these fixtures in a local test harness:\n\n```\n{\"priority\":\"P1\",\"estimate\":8,\"customerImpact\":\"Checkout is blocked\"}\n{\"priority\":\"urgent\",\"estimate\":-4,\"mysteryField\":true}\n```\n\nThe second should produce three errors. These are expected outcomes from reading the unexecuted template, not recorded test results.\n\n``` php\nMCP client\n  -> tool input validation\n  -> authorization and repository policy\n  -> GitHub API call\n```\n\nValidation is not authorization. A perfectly shaped request can still target the wrong repository or issue. A production tool also needs authenticated identity, least privilege, field discovery from official interfaces, write confirmation, rate-limit handling, and audit records.\n\nCommon beginner mistakes are checking only JSON syntax, silently converting every value, ignoring unknown fields, and copying a teaching schema into production.\n\nAfter this project, you should be able to explain parsing versus validation, type versus domain constraints, and why tool schemas do not replace authorization. Issue fields provide the current topic; the durable skill is making structured tools fail clearly at their boundary.", "url": "https://wpnews.pro/news/learn-schema-validation-with-a-tiny-github-issue-fields-project", "canonical_source": "https://dev.to/magickong/learn-schema-validation-with-a-tiny-github-issue-fields-project-9", "published_at": "2026-07-16 04:00:10+00:00", "updated_at": "2026-07-16 04:04:41.069596+00:00", "lang": "en", "topics": ["developer-tools", "machine-learning"], "entities": ["GitHub"], "alternates": {"html": "https://wpnews.pro/news/learn-schema-validation-with-a-tiny-github-issue-fields-project", "markdown": "https://wpnews.pro/news/learn-schema-validation-with-a-tiny-github-issue-fields-project.md", "text": "https://wpnews.pro/news/learn-schema-validation-with-a-tiny-github-issue-fields-project.txt", "jsonld": "https://wpnews.pro/news/learn-schema-validation-with-a-tiny-github-issue-fields-project.jsonld"}}