diff options
| author | erdgeist <erdgeist@erdgeist.org> | 2026-07-31 14:17:40 +0200 |
|---|---|---|
| committer | erdgeist <erdgeist@erdgeist.org> | 2026-07-31 14:17:40 +0200 |
| commit | a7cdc1856450c28491118d8143838e4b58ba2142 (patch) | |
| tree | 313f5a8630eeb43180d547b51bc633b1ee8176e8 /app/models | |
| parent | 2a658f721def1f6646077b9687d53b36a928d021 (diff) | |
Validate format of slug to be alphanum or _-
Diffstat (limited to 'app/models')
| -rw-r--r-- | app/models/node.rb | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/app/models/node.rb b/app/models/node.rb index 602382fb..c8f9a210 100644 --- a/app/models/node.rb +++ b/app/models/node.rb | |||
| @@ -34,6 +34,8 @@ class Node < ApplicationRecord | |||
| 34 | validates_presence_of :slug, :unless => -> { parent_id.nil? } | 34 | validates_presence_of :slug, :unless => -> { parent_id.nil? } |
| 35 | validates_uniqueness_of :slug, :scope => :parent_id, :unless => -> { parent_id.nil? } | 35 | validates_uniqueness_of :slug, :scope => :parent_id, :unless => -> { parent_id.nil? } |
| 36 | validates_presence_of :parent_id, :unless => -> { Node.root.nil? } | 36 | validates_presence_of :parent_id, :unless => -> { Node.root.nil? } |
| 37 | validates_format_of :slug, :with => /\A[A-Za-z0-9][A-Za-z0-9_-]*\z/, | ||
| 38 | :unless => -> { parent_id.nil? || slug.blank? } | ||
| 37 | 39 | ||
| 38 | validate :reserved_slug_stays_reserved | 40 | validate :reserved_slug_stays_reserved |
| 39 | validate :no_head_inside_trash | 41 | validate :no_head_inside_trash |
