From 45f86e62f2f1c189a787ca87df49d24d2a026835 Mon Sep 17 00:00:00 2001 From: goodmice Date: Thu, 2 Dec 2021 15:09:12 +0500 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=D1=8B=20=D0=BF=D1=80=D0=B0=D0=B2=D0=B8=D0=BB=D0=B0=20?= =?UTF-8?q?=D0=B2=D0=B0=D0=BB=D0=B8=D0=B4=D0=B0=D1=86=D0=B8=D0=B8=20=D0=BF?= =?UTF-8?q?=D0=BE=D0=BB=D0=B5=D0=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/utils/validationRules.ts | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 src/utils/validationRules.ts diff --git a/src/utils/validationRules.ts b/src/utils/validationRules.ts new file mode 100644 index 0000000..b439398 --- /dev/null +++ b/src/utils/validationRules.ts @@ -0,0 +1,35 @@ +import { Rule } from 'rc-field-form/lib/interface' + +export const loginRules: Rule[] = [{ + min: 3, + max: 255, + message: 'Допустимая длина 3-255 символов' +}, { + pattern: /^[A-Za-zА-Яа-я][А-Яа-я\w.-]+$/, + whitespace: true, + message: 'Логин должен начинаться с русской или латинской буквы, содержать только (А-яA-z0-9_-.)!' +}] + +export const nameRules: Rule[] = [{ + min: 1, + max: 255, + message: 'Допустимая длина 1-255 символов!' +}, { + pattern: /^[A-zА-я][A-zА-я-]*$/, + message: 'Допустимые символы: А-яA-z-' +}] + +export const phoneRules: Rule[] = [{ + pattern: /^(?:\+7|8)\s?(?:\(\d{3}\)|\d{3})\s?\d{3}-?\d{2}-?\d{2}$/, + message: 'Номер телефона должен иметь вид: +7 (xxx) xxx-xx-xx' +}] + +export const emailRules: Rule[] = [{ + type: 'email', + message: 'E-mail должен иметь вид: "user@site.domain"' +}] + +export const passwordRules: Rule[] = [{ + required: true, + message: 'Поле не может быть пустым!' +}]