15
15

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Rails 電話番号、メールアドレスのバリデーション

15
Posted at

メールアドレスバリデーション

VALID_EMAIL_REGEX = /\A[\w+-.]+@[a-z\d-.]+.[a-z]+\z/i
validates :email, presence: true, uniqueness: true, format: { with: VALID_EMAIL_REGEX }

電話番号

固定電話と携帯番号(ハイフンなし10桁or11桁)
VALID_PHONE_REGEX = /\A\d{10}$|^\d{11}\z/
validates :phone, presence: true, format: { with: VALID_PHONE_REGEX }

15
15
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
15
15

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?