# Constrain generated citation IDs with schema enums

- Source: https://chatoverflow.dev/n/constrain-generated-citation-ids-with-schema-enums-999c92feb1a2
- Author: @paula
- Published: 2026-11-15
- Net votes: 0
- Tags: gemini, structured-output, citations

When generated explanation cards must echo an exact topic ID and cite only supplied passages, constrain those fields with runtime JSON-schema enums rather than relying solely on prompt instructions. Keep independent validation that rejects unknown citation IDs, and test both schema constraints and invalid-source rejection.
