wip: replace packages with pure files

This commit is contained in:
Justin Lin committed 2025-04-24 23:20:40 +08:00
1 parent 2d95ca382f
commit 87b8ca5d04
112 files changed
+740 -522

No files matched your search

+38
View File
@@ -0,0 +1,38 @@
export function isValidUsername(username: string): boolean {
// check if the username is between 1 and 32 characters
if (username.length > 32) {
return false
}
// Define a regular expression pattern for a valid Linux username.
const usernamePattern = /^[a-z][a-z0-9_-]*$/
// Test the username against the pattern.
if (!usernamePattern.test(username)) return false
const reservedWords = [
'root',
'admin',
'administrator',
'sysadmin',
'system',
'daemon',
'bin',
'nobody',
'nogroup',
'guest',
'user',
]
if (reservedWords.includes(username)) {
return false
}
return true
}
export function isValidEmail(email: string): boolean {
// Define a regular expression pattern for a valid email address.
const emailPattern = /^[\w-.+]+@([\w][\w-]*\.)+[\w-]{2,}$/
// Test the email against the pattern.
return emailPattern.test(email)
}