Skip to content

Commit

Permalink
Add stronger validations for email addresses
Browse files Browse the repository at this point in the history
to avoid problems while sending and allow the sender to correct the
mistake.

[#1359]
  • Loading branch information
zaziemo committed May 21, 2024
1 parent 3ac0acf commit 5820e05
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion app/services/message.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class Message
attr_accessor :name, :email, :subject, :body

validates :name, :email, :subject, :body, presence: true
validates :email, format: { with: /.+@.+\..+/ }, allow_blank: false
validates :email, format: { with: /\A([\w.%+-]+)@([\w-]+.)+([\w]{2,})\z/i }, allow_blank: false

def initialize(attributes = {})
attributes.each do |name, value|
Expand Down

0 comments on commit 5820e05

Please sign in to comment.