Commit 23d59971 authored by Rémy Coutable's avatar Rémy Coutable

Merge branch 'frozen-string-enable-app-validators' into 'master'

Enable frozen string in apps/validators/*.rb

See merge request gitlab-org/gitlab-ce!20220
parents 0482e706 720ed6f6
# frozen_string_literal: true
class AbstractPathValidator < ActiveModel::EachValidator
extend Gitlab::EncodingHelper
......
# frozen_string_literal: true
class CertificateFingerprintValidator < ActiveModel::EachValidator
FINGERPRINT_PATTERN = /\A([a-zA-Z0-9]{2}[\s\-:]?){16,}\z/.freeze
......
# frozen_string_literal: true
# UrlValidator
#
# Custom validator for private keys.
......
# frozen_string_literal: true
# UrlValidator
#
# Custom validator for private keys.
......
# frozen_string_literal: true
# ClusterNameValidator
#
# Custom validator for ClusterName.
......
# frozen_string_literal: true
# ColorValidator
#
# Custom validator for web color codes. It requires the leading hash symbol and
......
# frozen_string_literal: true
# CronTimezoneValidator
#
# Custom validator for CronTimezone.
......
# frozen_string_literal: true
# CronValidator
#
# Custom validator for Cron.
......
# frozen_string_literal: true
# DurationValidator
#
# Validate the format conforms with ChronicDuration
......
# frozen_string_literal: true
class EmailValidator < ActiveModel::EachValidator
def validate_each(record, attribute, value)
record.errors.add(attribute, :invalid) unless value =~ Devise.email_regexp
......
# frozen_string_literal: true
class KeyRestrictionValidator < ActiveModel::EachValidator
FORBIDDEN = -1
......
# frozen_string_literal: true
# LineCodeValidator
#
# Custom validator for GitLab line codes.
......
# frozen_string_literal: true
# NamespaceNameValidator
#
# Custom validator for GitLab namespace name strings.
......
# frozen_string_literal: true
class NamespacePathValidator < AbstractPathValidator
extend Gitlab::EncodingHelper
......
# frozen_string_literal: true
class ProjectPathValidator < AbstractPathValidator
extend Gitlab::EncodingHelper
......
# frozen_string_literal: true
# PublicUrlValidator
#
# Custom validator for URLs. This validator works like UrlValidator but
......
# frozen_string_literal: true
class TopLevelGroupValidator < ActiveModel::EachValidator
def validate_each(record, attribute, value)
if value&.subgroup?
......
# frozen_string_literal: true
# UrlValidator
#
# Custom validator for URLs.
......
# frozen_string_literal: true
# VariableDuplicatesValidator
#
# This validator is designed for especially the following condition
......@@ -22,8 +24,8 @@ class VariableDuplicatesValidator < ActiveModel::EachValidator
def validate_duplicates(record, attribute, values)
duplicates = values.reject(&:marked_for_destruction?).group_by(&:key).select { |_, v| v.many? }.map(&:first)
if duplicates.any?
error_message = "have duplicate values (#{duplicates.join(", ")})"
error_message += " for #{values.first.send(options[:scope])} scope" if options[:scope] # rubocop:disable GitlabSecurity/PublicSend
error_message = +"have duplicate values (#{duplicates.join(", ")})"
error_message << " for #{values.first.send(options[:scope])} scope" if options[:scope] # rubocop:disable GitlabSecurity/PublicSend
record.errors.add(attribute, error_message)
end
end
......
---
title: Enable frozen string in apps/validators/*.rb
merge_request: 20220
author: gfyoung
type: other
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment