0
0

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 1 year has passed since last update.

独自のバリデーションを定義する

Posted at

validate

説明

バリデーションを定義

使い方

validate(バリデーションメソッド名.., ブロック引数)

失敗したら例外発生

validate!(バリデーションメソッド名.., ブロック引数)

バリデーションを定義

validate :must_be_friends

ブロック

validate do |comment|
  comment.must_be_friends
end

出典

感想

種類のないバイデーションを作成することができる。
:バリデーションメソッドを指定できることが勉強になった。

0
0
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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?