Added validation for name: Should not include a http(s) url (#2114)

This commit is contained in:
Henning 2020-09-22 16:46:17 +02:00 committed by GitHub
parent 816cefe1b6
commit 75b989240a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 1 deletions

View File

@ -35,7 +35,8 @@ class User < ApplicationRecord
belongs_to :role, required: false
validates :name, length: { maximum: 256 }, presence: true
validates :name, length: { maximum: 256 }, presence: true,
format: { without: %r{https?://}i }
validates :provider, presence: true
validate :check_if_email_can_be_blank
validates :email, length: { maximum: 256 }, allow_blank: true,

View File

@ -27,6 +27,7 @@ describe User, type: :model do
context 'validations' do
it { should validate_presence_of(:name) }
it { should validate_length_of(:name).is_at_most(256) }
it { should_not allow_value("https://www.bigbluebutton.org").for(:name) }
it { should validate_presence_of(:provider) }