Polarcraft/web/server/utils/check.js

16 lines
329 B
JavaScript

export const isHexColor = (str) => {
const pattern = /^#([0-9A-F]{3}){1,2}$/i;
return pattern.test(str);
}
export const verifyUsername = (username) => {
const alphanumeric = /^[a-zA-Z0-9]+$/;
if (username.length > 20) {
return false;
}
if (!alphanumeric.test(username)) {
return false;
}
return true;
}