improve user email validation

This commit is contained in:
Alex Turchyn authored and Pete Matsyburka committed 2025-05-29 14:24:17 +03:00
1 parent 8b9678a434
commit fa0733f480
4 files changed
+37

No files matched your search

+2
View File
@@ -73,6 +73,8 @@ 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/ }
def access_token
super || build_access_token.tap(&:save!)
end