What is the best/easy way to validate an email address in Ruby?

前端 未结 10 871
刺人心
刺人心 2020-12-13 06:40

What is the best/easy way to validate an email address in ruby (on the server side)?

10条回答
  •  温柔的废话
    2020-12-13 06:58

    You can take reference from https://apidock.com/rails/ActiveModel/Validations/HelperMethods/validates_format_of

    validates_format_of :email, with: /\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\z/i

提交回复
热议问题