bright-action-91775
09/25/2025, 9:46 PMchilly-king-10285
09/25/2025, 9:47 PMchilly-king-10285
09/25/2025, 9:47 PMjson { "$id": "<https://example.com/registration.schema.json>", "$schema": "<http://json-schema.org/draft-07/schema#>", "title": "Person", "type": "object", "properties": { "traits": { "type": "object", "properties": { "email": { "type": "string", "format": "email", "<http://ory.sh/kratos|ory.sh/kratos>": { "credentials": { "password": { "identifier": true } } } }, "username": { "type": "string", "<http://ory.sh/kratos|ory.sh/kratos>": { "credentials": { "password": { "identifier": true } } } } }, "anyOf": [ { "required": ["email"] }, { "required": ["username"] } ], "additionalProperties": false } } }
- This schema allows an identity to have only an email, only a username, or both. - Both fields are marked as identifiers, so either can be used to log in. - The anyOf keyword ensures that at least one of the fields is present. This approach is consistent with Ory’s support for multiple identifiers and flexible identity schemas, as described in the documentation and examples provided, though the exact use of anyOf is not shown in the docs, it is a standard JSON Schema feature and aligns with Ory’s schema validation approach [Customize identity schemas](https://www.ory.sh/docs/kratos/manage-identities/customize-identity-schema#multiple-identifiers). If you need more advanced validation (e.g., enforcing at least one of several fields), refer to the [advanced validation section](https://www.ory.sh/docs/kratos/manage-identities/customize-identity-schema#more-advanced-validation) for further JSON Schema techniques. Note: The knowledge sources do not provide a direct, copy-paste example of this exact scenario, but the approach above is derived from the documented schema flexibility and JSON Schema capabilities supported by Ory.