From 17fd942459ba9353a51ce74ad9ccad7b8f93b772 Mon Sep 17 00:00:00 2001 From: dinsmol Date: Fri, 23 Jul 2021 10:57:00 +0300 Subject: [PATCH] added name_regexp --- app/models/contact.rb | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/models/contact.rb b/app/models/contact.rb index 27e55428b..ea422041e 100644 --- a/app/models/contact.rb +++ b/app/models/contact.rb @@ -28,6 +28,9 @@ class Contact < ApplicationRecord .where('success = false and verified_at IS NOT NULL') } + NAME_REGEXP = /([\u00A1-\u00B3\u00B5-\u00BF\u0021-\u0026\u0028-\u002C\u003A-\u0040]| + [\u005B-\u005F\u007B-\u007E\u2040-\u206F\u20A0-\u20BF\u2100-\u218F])/x.freeze + validates :name, :email, presence: true validates :name, format: { without: NAME_REGEXP, message: :invalid }, if: -> { priv? }