Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support slugs? #17

Closed
zomars opened this issue Jun 25, 2022 · 3 comments
Closed

Support slugs? #17

zomars opened this issue Jun 25, 2022 · 3 comments

Comments

@zomars
Copy link

zomars commented Jun 25, 2022

I see that your username function may generate usernames with dots in them. In our use case we need to generate username with only alphanumeric characters and maybe dashes and underscores.

@justinvdm
Copy link
Contributor

justinvdm commented Jun 27, 2022

Hey @zomars, thanks for the request. I'm going back and forth on whether to add an option for copycat.username() for this.

What do you think about just using other copycat functions on your side to put this together? e.g.

import { copycat as c } from '@snaplet/copycat'

const username = x => `${c.firstName(x)}-${c.lastName(x)}${c.int(x, { min: 2, max: 99 })}`

or for dashes or underscores:

import { copycat as c } from '@snaplet/copycat'

const username = x => [c.firstName(x), c.oneOf(x, ['_', '-']), c.lastName(x), c.int(x, { min: 2, max: 99 })].join('')

@zomars
Copy link
Author

zomars commented Jun 27, 2022

This can work for now. Thanks for the insights 🙏🏽

@justinvdm
Copy link
Contributor

Awesome, thanks @zomars :) Closing for now then.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants