-
Notifications
You must be signed in to change notification settings - Fork 480
docs: document enum identity schema dropdowns #2508
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -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. | ||||||||||||||||||
|
|
||||||||||||||||||
| ```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
|
||||||||||||||||||
| 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. |
There was a problem hiding this comment.
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.