Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions docs/kratos/manage-identities/15_customize-identity-schema.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,43 @@ their GitHub handle, which is clear thanks to the field description defined in t
</Tabs>
````

## Restrict values with `enum`

Use the JSON Schema `enum` keyword to restrict a trait to a fixed set of allowed values. When you declare an `enum` on a string
property, the Ory Account Experience renders the field as a dropdown (a native `<select>`) and only accepts values from the list
at registration, settings, and admin updates.
Copy link

Copilot AI Apr 14, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

“admin updates” is ambiguous in this context (Kratos typically refers to “Admin API” / “admin endpoints” rather than a generic “admin updates”). Consider rephrasing to explicitly name the surface (e.g., “via the Admin API”) so readers know where enum validation applies.

Suggested change
at registration, settings, and admin updates.
at registration, in settings, and via the Admin API.

Copilot uses AI. Check for mistakes.

```json
{
"$schema": "http://json-schema.org/draft-07/schema#",
"type": "object",
"properties": {
"traits": {
"type": "object",
"properties": {
"country": {
"type": "string",
"title": "Country",
"enum": ["US", "UK", "DE", "AT"]
}
},
"required": ["country"]
}
}
}
```

Ory Kratos surfaces the allowed values on the UI node by attaching an `options` array to the input attributes. Custom UIs that
already know how to render a UI node can read `attributes.options` and display a `<select>`; UIs that do not look at `options`
fall back to a plain text input, so the change is backward compatible with older custom UIs.
Comment on lines +234 to +236
Copy link

Copilot AI Apr 14, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The text references attributes.options, but it’s not fully clear what object attributes belongs to. Consider explicitly using the full path (for example, UI node → node.attributes.options) and briefly stating what each option entry contains, so custom UI implementers can locate and render the dropdown data reliably.

Suggested change
Ory Kratos surfaces the allowed values on the UI node by attaching an `options` array to the input attributes. Custom UIs that
already know how to render a UI node can read `attributes.options` and display a `<select>`; UIs that do not look at `options`
fall back to a plain text input, so the change is backward compatible with older custom UIs.
Ory Kratos surfaces the allowed values on the UI node by attaching an `options` array to the input's attributes object
(`node.attributes.options`). Each entry in `node.attributes.options` represents one dropdown choice and contains the option
value and label used to render the native `<select>`. Custom UIs that already know how to render a UI node can read
`node.attributes.options` and display a `<select>`; UIs that do not look at `options` fall back to a plain text input, so the
change is backward compatible with older custom UIs.

Copilot uses AI. Check for mistakes.

:::note

Only top-level string properties under `traits` are supported. The rendered option value is used as both the submitted value and
the visible label.

:::

## Identity schema extensions

Because the system doesn't know which fields have system-relevant meaning, you have to specify that in the schema. For example:
Expand Down
Loading