Skip to content

Commit

Permalink
fix:format email add-validators
Browse files Browse the repository at this point in the history
  • Loading branch information
BarbaraOliveira13 committed Aug 30, 2024
1 parent 1c91e02 commit c82e48f
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions app/validators/email_validators.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
module Decidim
module FriendlySignup
class EmailValidator < ActiveModel::EachValidator
CUSTOM_EMAIL_REGEX = /\A[^<>"']+@[a-zA-Z0-9\-.]+\.[a-zA-Z]{2,}/

def validate_each(record, attribute, value)
unless value =~ CUSTOM_EMAIL_REGEX
record.errors.add(attribute, :invalid_format, message: I18n.t("errors.messages.email.invalid_format"))
end
end
end
end
end

0 comments on commit c82e48f

Please sign in to comment.