separate validation logic to simplify testing and use same logic as backend

This commit is contained in:
Sebastian Sdorra
2018-07-27 10:14:55 +02:00
parent f5033290e2
commit 92d0fc6e69
3 changed files with 194 additions and 29 deletions

View File

@@ -0,0 +1,24 @@
// @flow
const nameRegex = /^([A-z0-9\.\-_@]|[^ ]([A-z0-9\.\-_@ ]*[A-z0-9\.\-_@]|[^\s])?)$/;
export const isNameValid = (name: string) => {
return nameRegex.test(name);
};
export const isDisplayNameValid = (displayName: string) => {
if (displayName) {
return true;
}
return false;
};
const mailRegex = /^[A-z0-9][\w.-]*@[A-z0-9][\w\-\.]*\.[A-z0-9][A-z0-9-]+$/;
export const isMailValid = (mail: string) => {
return mailRegex.test(mail);
};
export const isPasswordValid = (password: string) => {
return password.length > 6 && password.length < 32;
};