BA
Better Authβ€’2mo ago
kubas

How to check if slug has spaces before the organization creation?

Hey all! I want to check if slug has spaces, if it has, return custom error so you can display error message on frontend "slug is invalid". I know about the beforeCreate and allowUserToCreateOrganization functions, but as far as I know, there is no way to return custom error message, to handle it on frontend.
Solution:
why not just validate client side before submission to the API endpoint
Jump to solution
7 Replies
Solution
The Untraceable
The Untraceableβ€’2mo ago
why not just validate client side before submission to the API endpoint
The Untraceable
The Untraceableβ€’2mo ago
or just slugify the users input (converting spaces to - or whatever)
kubas
kubasOPβ€’2mo ago
i just tought there is a way and i dont need to create my own wrapper
The Untraceable
The Untraceableβ€’2mo ago
I guess you could call the checkSlug function and return an error based on that
kubas
kubasOPβ€’2mo ago
is it in auth client?
The Untraceable
The Untraceableβ€’2mo ago
Yeah
const { data, error } = await authClient.organization.checkSlug({
slug: "my-org", // required
});
const { data, error } = await authClient.organization.checkSlug({
slug: "my-org", // required
});
kubas
kubasOPβ€’2mo ago
Thank you brother!! πŸ™πŸΌπŸ™πŸΌ

Did you find this page helpful?