:wave: Hello, team! I am using Kratos's admin API...
# talk-kratos
s
👋 Hello, team! I am using Kratos's admin API to create an identity. I am doing it on a nodejs server using
@ory/kratos-client v0.10.1
I am able to create the user. But the issue is kratos is not running any validations on the password. is there any way to validate the password in recommended way. Thanks here is the code:
Copy code
const client = new V0alpha2Api(
  new Configuration({
    basePath: process.env.KRATOS_ADMIN_URL,
    baseOptions: {
      withCredentials: true,
    },
  })
);

const resp = await client.adminCreateIdentity({
  traits: {
    name: {
      first: "xy",
      last: "x",
    },
    email: "<mailto:admin@xyz.com|admin@xyz.com>",
  },
  schema_id: "default",
  credentials: {
    password: {
      config: {
        password,
      },
    },
  },
});
identity.schema.json
Copy code
{
  "$id": "<https://schemas.ory.sh/presets/kratos/quickstart/email-password/identity.schema.json>",
  "$schema": "<http://json-schema.org/draft-07/schema#>",
  "title": "Person",
  "type": "object",
  "properties": {
    "traits": {
      "type": "object",
      "properties": {
        "email": {
          "type": "string",
          "format": "email",
          "title": "E-Mail",
          "minLength": 3,
          "<http://ory.sh/kratos|ory.sh/kratos>": {
            "credentials": {
              "password": {
                "identifier": true
              }
            },
            "verification": {
              "via": "email"
            },
            "recovery": {
              "via": "email"
            }
          }
        },
        "name": {
          "type": "object",
          "properties": {
            "first": {
              "title": "First Name",
              "type": "string"
            },
            "last": {
              "title": "Last Name",
              "type": "string"
            }
          }
        }
      },
      "required": [
        "email"
      ],
      "additionalProperties": false
    }
  }
}
m
Hello Akshaydeep see this document: https://www.ory.sh/docs/kratos/self-service/flows/user-registration#registration-form-validation
For API Clients, the server typically responds with HTTP 400 Bad Request and the Registration Flow in the response payload as JSON.
s
Thanks let me check