diff options
Diffstat (limited to 'app/models/error_tracking/project_error_tracking_setting.rb')
-rw-r--r-- | app/models/error_tracking/project_error_tracking_setting.rb | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/app/models/error_tracking/project_error_tracking_setting.rb b/app/models/error_tracking/project_error_tracking_setting.rb index a7dbff8f186..47cf35511e9 100644 --- a/app/models/error_tracking/project_error_tracking_setting.rb +++ b/app/models/error_tracking/project_error_tracking_setting.rb @@ -10,11 +10,9 @@ module ErrorTracking validates :api_url, length: { maximum: 255 }, public_url: true, url: { enforce_sanitization: true, ascii_only: true }, allow_nil: true - validates :api_url, presence: true, if: :enabled - validate :validate_api_url_path, if: :enabled - validates :token, presence: true, if: :enabled + validate :validate_api_url_token_presence, if: :enabled attr_encrypted :token, mode: :per_attribute_iv, @@ -120,6 +118,16 @@ module ErrorTracking @slug_match[capture] end + def validate_api_url_token_presence + if self.api_url.blank? + errors.add(:base, 'Sentry API URL is a required field.') + end + + if self.token.blank? + errors.add(:base, 'Sentry API Auth Token is a required field.') + end + end + def validate_api_url_path return if api_url.blank? |