mirror of
https://github.com/filecoin-project/slate.git
synced 2024-12-25 18:13:10 +03:00
29 lines
492 B
JavaScript
29 lines
492 B
JavaScript
|
import * as Strings from "~/common/strings";
|
||
|
|
||
|
const USERNAME_REGEX = new RegExp("^[a-zA-Z0-9_]{0,}[a-zA-Z]+[0-9]*$");
|
||
|
const MIN_PASSWORD_LENGTH = 8;
|
||
|
|
||
|
export const username = (text) => {
|
||
|
if (Strings.isEmpty(text)) {
|
||
|
return false;
|
||
|
}
|
||
|
|
||
|
if (!USERNAME_REGEX.test(text)) {
|
||
|
return false;
|
||
|
}
|
||
|
|
||
|
return true;
|
||
|
};
|
||
|
|
||
|
export const password = (text) => {
|
||
|
if (Strings.isEmpty(text)) {
|
||
|
return false;
|
||
|
}
|
||
|
|
||
|
if (text.length < MIN_PASSWORD_LENGTH) {
|
||
|
return false;
|
||
|
}
|
||
|
|
||
|
return true;
|
||
|
};
|