feat: update editor validation to ignore html

This commit is contained in:
Vladimir Iliev 2020-05-08 12:02:07 +03:00
Родитель 5daeb723ec
Коммит dd48b53a80
1 изменённых файлов: 2 добавлений и 1 удалений

Просмотреть файл

@ -1,7 +1,8 @@
const emailRegex = new RegExp(/^\w+([.-]?\w+)*@\w+([.-]?\w+)*(\.\w{2,3})+$/);
const phoneRegex = new RegExp(/^[0-9 ()+-]+$/);
const htmlRegex = new RegExp(/<[^>]*>/g);
export const emailValidator = (value) => (emailRegex.test(value) ? '' : 'You have entered an invalid email address!');
export const requiredValidator = (value) => value ? '' : 'This field is required';
export const phoneValidator = (value) => value && phoneRegex.test(value) ? '' : 'Please enter valid phone number.';
export const biographyValidator = (value) => value && value.length > 50 ? '' : 'Biography must be at least 50 characters long.';
export const biographyValidator = (value) => value && value.replace(htmlRegex, '').length >= 50 ? '' : 'Biography must be at least 50 characters long.';