An enum field allows only a fixed list of values, such as low, medium or high. Constraining a field to an enum stops the model inventing a fourth value such as urgent-ish, which would break code that reads the field. Check the reply against the list every time, even when the model supports structured output.
Checked on 2026-11-29. We did not run any tool for this guide. Every result below is an expected result, marked UNTESTED, for you to confirm on your own files.
Prerequisites
- A schema with one enum field and its allowed values
- A model that supports structured output
- A test prompt that invites a value outside the list
Steps
1. Write the allowed list
List the values in the schema, for example status with todo, doing and done. Keep the list short.
Expected result: An allowed list of three values is written in the schema.
2. Send a prompt that tempts a new value
Ask about a case that sits between two values, so the model is tempted to invent one.
Expected result: A test prompt exists that tempts an out-of-list value.
3. Check the reply value against the list
Read the field and compare it exactly with the list. Case and spelling must match.
Expected result: The reply value is marked inside or outside the list.
4. Retry or map the miss
If the value is outside the list, retry once. If it still misses, map it by hand or reject the reply.
Expected result: A retry and a reject path exist, and no out-of-list value reaches your code.
Worked example
A practice schema allows three priority values. The model replied with a fourth value on the first try.
| Reply | Value | In list? |
|---|---|---|
| First try | critical | No |
| Retry | high | Yes |
| Allowed list | low, medium, high | – |
Expected result: The first reply is rejected for using critical, and the retry returns high, which is in the list (UNTESTED – confirm it yourself.)
Verdict table
| Check | Expected result | Pass? |
|---|---|---|
| Write the allowed list | An allowed list of three values is written in the schema. | – |
| Send a prompt that tempts a new value | A test prompt exists that tempts an out-of-list value. | – |
| Check the reply value against the list | The reply value is marked inside or outside the list. | – |
| Retry or map the miss | A retry and a reject path exist, and no out-of-list value reaches your code. | – |
Limits
- An enum only constrains the value, not whether the value is correct for the case.
- Some models ignore enum constraints when the prompt is vague; keep the prompt specific.
Sources
- Ollama v0.12.6 release notes – checked 2026-11-29
- Ollama v0.12.10 release notes – checked 2026-11-29
- Ollama v0.11.0 release notes – checked 2026-11-29
