Create a TypeScript function that scores a climate tech project entry for metadata quality. ```typescript validateProjectMetadata(project: RawProject): ValidationResult // RawProject: { name?: string, description?: string, repo_url?: string, category?: string, license?: string, [key: string]: unknown } // ValidationResult: { valid: boolean, score: number, missing: string[], warnings: string[] } ``` Scoring rules (100 points max): - `name` present and non-empty: +20 - `description` present and length > 50 chars: +20 - `repo_url` present and matches `https://github.com/*`: +20 - `category` is from the allowed list (export a `VALID_CATEGORIES` constant): +20 - `license` is a recognized SPDX identifier (MIT, Apache-2.0, GPL-3.0, AGPL-3.0, BSD-2-Clause, BSD-3-Clause, MPL-2.0): +20 Warnings (reduce score by 10 each, floor at 0): - Description is present but under 50 chars - repo_url is present but not a GitHub URL - License is present but not in the SPDX list `valid` is `true` if score >= 60. Write unit tests for: a perfect entry, a partial entry missing 2 fields, an entry with warnings only, and an empty object.
No contributions yet.