Skip to content

Commit 8437f92

Browse files
committed
feat: News モデルにバリデーションを追加
バリデーション内容: ✅ title: 必須項目 ✅ url: 必須項目 + 重複禁止 + HTTP/HTTPS形式チェック ✅ published_at: 必須項目 目的: - データの整合性を保証 - 重複URLの防止
1 parent 1cbcc66 commit 8437f92

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

app/models/news.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
11
class News < ApplicationRecord
22
scope :recent, -> { order(published_at: :desc) }
3+
4+
validates :title, presence: true
5+
validates :url, presence: true,
6+
uniqueness: true,
7+
format: { with: /\Ahttps?:\/\/.*\z/i }
8+
validates :published_at, presence: true
39
end

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy