Error codes and mapping to fields

type ErrorTypes = Partial<
  Record<
    keyof typeof authClient.$ERROR_CODES,
    {
      field?: keyof z.infer<typeof formSchema> | "root";
      message: string;
    }
  >
>;

const errorMap: ErrorTypes = {
  USER_ALREADY_EXISTS_USE_ANOTHER_EMAIL: {
    field: "email",
    message: "Email already exists",
  },
  INVALID_PASSWORD: {
    field: "password",
    message: "Password does not meet requirements",
  },
};

I'm trying to create a way to map error types to fields. However, when I log the actual error code that, I recieve I get: USER_ALREADY_EXISTS_USE_ANOTHER_EMAIL. However this isnt defined in $ERROR_CODES. Does this mean there are error codes that I could receive that aren't defined in the type?
Was this page helpful?