mirror of
https://github.com/mastodon/mastodon.git
synced 2025-01-17 15:47:15 +01:00
Extract CSS_COLORS
constant for UserRole
regex validation (#33532)
This commit is contained in:
parent
846c89b66e
commit
4fb3dc0363
@ -42,6 +42,7 @@ class UserRole < ApplicationRecord
|
|||||||
NOBODY_POSITION = -1
|
NOBODY_POSITION = -1
|
||||||
|
|
||||||
POSITION_LIMIT = (2**31) - 1
|
POSITION_LIMIT = (2**31) - 1
|
||||||
|
CSS_COLORS = /\A#?(?:[A-F0-9]{3}){1,2}\z/i # CSS-style hex colors
|
||||||
|
|
||||||
module Flags
|
module Flags
|
||||||
NONE = 0
|
NONE = 0
|
||||||
@ -90,7 +91,7 @@ class UserRole < ApplicationRecord
|
|||||||
attr_writer :current_account
|
attr_writer :current_account
|
||||||
|
|
||||||
validates :name, presence: true, unless: :everyone?
|
validates :name, presence: true, unless: :everyone?
|
||||||
validates :color, format: { with: /\A#?(?:[A-F0-9]{3}){1,2}\z/i }, unless: -> { color.blank? }
|
validates :color, format: { with: CSS_COLORS }, if: :color?
|
||||||
validates :position, numericality: { in: (-POSITION_LIMIT..POSITION_LIMIT) }
|
validates :position, numericality: { in: (-POSITION_LIMIT..POSITION_LIMIT) }
|
||||||
|
|
||||||
validate :validate_permissions_elevation
|
validate :validate_permissions_elevation
|
||||||
|
Loading…
x
Reference in New Issue
Block a user