PromucFlow_constructor/app/client/src/utils/formhelpers.ts
Dmitriy Danilov 8f62ac93a1
Create Org Form: don't allow to use only spaces in names (#913)
Also disables the submit button when invalid
Fixes: #807, #621
2020-10-07 12:14:44 +05:30

24 lines
724 B
TypeScript

const PASSWORD_MIN_LENGTH = 6;
export const hashPassword = (password: string) => {
return password;
};
export const isEmptyString = (value: string) => {
return !value || value.trim().length === 0 || false;
};
export const isStrongPassword = (value: string) => {
return value.trim().length >= PASSWORD_MIN_LENGTH;
};
export const noSpaces = (value: string) => {
return !value || value.trim().length === 0;
};
// TODO (abhinav): Use a regex which adheres to standards RFC5322
export const isEmail = (value: string) => {
const re = /^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
return re.test(value);
};