Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7308113
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T23:30:47+00:00 2026-05-28T23:30:47+00:00

Trying to validate the email field in a rails devise app with a word

  • 0

Trying to validate the email field in a rails devise app with a word exclusion.

  validates :email, :exclusion => {:in => ["admin", "root",,
                                   :message => "is reserved"}

Wich works great on the :username field but not on the email.

I suspect that Devise is “taken over” the validation of the email field and I need to super/ overrule the registrations controller of Devise.

How could I:

  • Prevent emails with words based on an :exclusion
  • Prevent emails with @myapp.com so users don’t use the domain the app runs on.
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T23:30:47+00:00Added an answer on May 28, 2026 at 11:30 pm

    You can always write custom validations to achieve what you want. Example from the guide:

    The easiest way to add custom validators for validating individual
    attributes is with the convenient ActiveModel::EachValidator. In this
    case, the custom validator class must implement a validate_each method
    which takes three arguments: record, attribute and value which
    correspond to the instance, the attribute to be validated and the
    value of the attribute in the passed instance.

    class EmailValidator < ActiveModel::EachValidator
      def validate_each(record, attribute, value)
        unless value =~ /\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\z/i
          record.errors[attribute] << (options[:message] || "is not an email")
        end
      end
    end
    
    class Person < ActiveRecord::Base
      validates :email, :presence => true, :email => true
    end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I can't figure out where I'm going wrong here. Trying to validate an email
I'm trying to position the jquery validate message under the select box and text
I'm trying to remote validate a field by looking at two different fields. The
I'm trying to write a generalised function that validates my field through Jquery Ajax.
I'm trying to create a User model for my Ruby on Rails app that
I am trying to use the client_side_validations gem with Devise to validate devise registrations
I've recently installed the paperclip gem to my Rails 3 app. I am trying
im trying to validate my form, but for some reason the SSN field wont
Hi I am using razor and trying to use regular expression to validate email
When trying to validate my site, I get the following error: Line 188, column

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.