Improvements to username and password validations (#1745)
* Fix: Improve special character regex (#1744) * update password special character regex to support ( `-` `_` `=` `+` `[` `]` `;` `'` `\` `/` ) * Fix: Allow usernames starting from 2 characters (#1744) * update username validation to support short usernames starting from 2 characters * remove char validation altogether --------- Co-authored-by: Bernd Storath <999999bst@gmail.com>
This commit is contained in:
committed by
GitHub
parent
d51f12a82f
commit
940edb2b0c
@@ -6,16 +6,12 @@ export type UserType = InferSelectModel<typeof user>;
|
||||
|
||||
const username = z
|
||||
.string({ message: t('zod.user.username') })
|
||||
.min(8, t('zod.user.username'))
|
||||
.min(2, t('zod.user.username'))
|
||||
.pipe(safeStringRefine);
|
||||
|
||||
const password = z
|
||||
.string({ message: t('zod.user.password') })
|
||||
.min(12, t('zod.user.password'))
|
||||
.regex(/[A-Z]/, t('zod.user.passwordUppercase'))
|
||||
.regex(/[a-z]/, t('zod.user.passwordLowercase'))
|
||||
.regex(/\d/, t('zod.user.passwordNumber'))
|
||||
.regex(/[!@#$%^&*(),.?":{}|<>]/, t('zod.user.passwordSpecial'))
|
||||
.pipe(safeStringRefine);
|
||||
|
||||
const remember = z.boolean({ message: t('zod.user.remember') });
|
||||
|
||||
Reference in New Issue
Block a user