validate email

This commit is contained in:
Pete Matsyburka committed 2026-11-07 09:37:32 +02:00
1 parent e39e84adfa
commit 92cfd5624d
2 files changed
+13 -2

No files matched your search

+3 -1
View File
@@ -56,6 +56,8 @@ class User < ApplicationRecord
FULL_EMAIL_REGEXP =
/\A[a-z0-9][.']?(?:(?:[a-z0-9_-]+[.+'])*[a-z0-9_-]+)*@(?:[a-z0-9]+[.-])*[a-z0-9]+\.[a-z]{2,}\z/i
VALIDATE_EMAIL_REGEXP = /\A[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}\z/
has_one_attached :signature
has_one_attached :initials
@@ -78,7 +80,7 @@ class User < ApplicationRecord
scope :archived, -> { where.not(archived_at: nil) }
scope :admins, -> { where(role: ADMIN_ROLE) }
validates :email, format: { with: /\A[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}\z/ }
validates :email, format: { with: VALIDATE_EMAIL_REGEXP }
def access_token
super || build_access_token.tap(&:save!)