Validate a gist dict against the schema. Returns list of error strings (empty = valid).
(gist: Dict)
| 529 | |
| 530 | |
| 531 | def validate_gist(gist: Dict) -> List[str]: |
| 532 | """Validate a gist dict against the schema. Returns list of error strings (empty = valid).""" |
| 533 | errors = [] |
| 534 | |
| 535 | for key in _GIST_REQUIRED_KEYS: |
| 536 | if key not in gist: |
| 537 | errors.append(f"missing top-level key: {key}") |
| 538 | |
| 539 | ai = gist.get("gist") |
| 540 | if ai is None: |
| 541 | errors.append("missing 'gist' object") |
| 542 | return errors |
| 543 | |
| 544 | for key in _GIST_AI_KEYS: |
| 545 | if key not in ai: |
| 546 | errors.append(f"missing gist.{key}") |
| 547 | |
| 548 | if ai.get("category") and ai["category"] not in VALID_CATEGORIES: |
| 549 | errors.append(f"invalid category: {ai['category']}") |
| 550 | if ai.get("publish_tier") and ai["publish_tier"] not in VALID_PUBLISH_TIERS: |
| 551 | errors.append(f"invalid publish_tier: {ai['publish_tier']}") |
| 552 | if ai.get("importance") and ai["importance"] not in VALID_IMPORTANCE: |
| 553 | errors.append(f"invalid importance: {ai['importance']}") |
| 554 | if "user_facing" in ai and not isinstance(ai["user_facing"], bool): |
| 555 | errors.append("user_facing must be boolean") |
| 556 | if "keywords" in ai and not isinstance(ai["keywords"], list): |
| 557 | errors.append("keywords must be a list") |
| 558 | |
| 559 | return errors |
| 560 | |
| 561 | |
| 562 | def apply_publish_tier_rules(gist: Dict) -> str: |