Directus User Registration with Required Custom Field "username"

I’ve added a required custom field username to my directus_users collection. When trying to register users with the SDK’s registerUser function, I get an error because the function doesn’t accept custom fields.

My Code:

export async function register(username, email, password) {
  try {
    const user = await directus.request(registerUser(
      email, 
      password,
      username
    ));
    return user;
  } catch (error) {
    console.error('User registration failed:', error);
    throw error;
  }
}

Error:

400 Bad Request: Invalid payload. "username" is not allowed.