Does anyone have any example code for sanitizing u...
# ory-selfhosting
l
Does anyone have any example code for sanitizing usernames to be alphanumeric only? https://www.ory.sh/docs/kratos/manage-identities/best-practices#sanitize-usernamestraits I understand it needs a regex, but there is no documentation on where this regex should go in the identity schema. Thanks!
Thanks to @wooden-nightfall-55264 it can be done like this:
Copy code
"username": {
  "type": "string",
  "minLength": 6,
  "maxLength": 32,
  "pattern": "^[a-zA-Z0-9]*$",
  "title": "Username",
  "<http://ory.sh/kratos|ory.sh/kratos>": {
    "credentials": {
      "password": {
        "identifier": true
      }
    }
  }
},
using the
"pattern"
with the regex pattern desired