Create a TypeScript function that scores a climate tech project entry for metadata quality.
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: +20description present and length > 50 chars: +20repo_url present and matches https://github.com/*: +20category is from the allowed list (export a VALID_CATEGORIES constant): +20license is a recognized SPDX identifier (MIT, Apache-2.0, GPL-3.0, AGPL-3.0, BSD-2-Clause, BSD-3-Clause, MPL-2.0): +20Warnings (reduce score by 10 each, floor at 0):
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.