Commit 2013de13 authored by Eugenia Grieff's avatar Eugenia Grieff

Modify only full-sentence errors

These errors are only the ones added to :base
and not a specific model attribute
parent 9a242a40
......@@ -38,7 +38,7 @@ class Appearance < ApplicationRecord
def single_appearance_row
if self.class.any?
errors.add(:single_appearance_row, _('Only 1 appearances row can exist'))
errors.add(:base, _('Only 1 appearances row can exist'))
end
end
......
......@@ -389,7 +389,7 @@ module ApplicationSettingImplementation
def terms_exist
return unless enforce_terms?
errors.add(:terms, "You need to set terms to be enforced") unless terms.present?
errors.add(:base, _('You need to set terms to be enforced')) unless terms.present?
end
def expire_performance_bar_allowed_user_ids_cache
......
......@@ -148,7 +148,7 @@ module Ci
def valid_file_format?
unless TYPE_AND_FORMAT_PAIRS[self.file_type&.to_sym] == self.file_format&.to_sym
errors.add(:file_format, _('Invalid file format with specified file type'))
errors.add(:base, _('Invalid file format with specified file type'))
end
end
......
......@@ -447,7 +447,7 @@ module Ci
def valid_commit_sha
if self.sha == Gitlab::Git::BLANK_SHA
self.errors.add(:sha, _(" cant be 00000000 (branch removal)"))
self.errors.add(:sha, " cant be 00000000 (branch removal)")
end
end
......
......@@ -299,7 +299,7 @@ module Ci
def tag_constraints
unless has_tags? || run_untagged?
errors.add(:tags_list,
_('can not be empty when runner is not allowed to pick untagged jobs'))
'can not be empty when runner is not allowed to pick untagged jobs')
end
end
......@@ -309,25 +309,25 @@ module Ci
def no_projects
if projects.any?
errors.add(:runner, _('cannot have projects assigned'))
errors.add(:runner, 'cannot have projects assigned')
end
end
def no_groups
if groups.any?
errors.add(:runner, _('cannot have groups assigned'))
errors.add(:runner, 'cannot have groups assigned')
end
end
def any_project
unless projects.any?
errors.add(:runner, _('needs to be assigned to at least one project'))
errors.add(:runner, 'needs to be assigned to at least one project')
end
end
def exactly_one_group
unless groups.one?
errors.add(:runner, _('needs to be assigned to exactly one group'))
errors.add(:runner, 'needs to be assigned to exactly one group')
end
end
......
......@@ -306,7 +306,7 @@ module Clusters
.where.not(id: id)
if duplicate_management_clusters.any?
errors.add(:environment_scope, _('cannot add duplicated environment scope'))
errors.add(:environment_scope, 'cannot add duplicated environment scope')
end
end
......@@ -380,7 +380,7 @@ module Clusters
def restrict_modification
if provider&.on_creation?
errors.add(:base, _('cannot modify during creation'))
errors.add(:base, _('Cannot modify provider during creation'))
return false
end
......@@ -389,13 +389,13 @@ module Clusters
def no_groups
if groups.any?
errors.add(:cluster, _('cannot have groups assigned'))
errors.add(:cluster, 'cannot have groups assigned')
end
end
def no_projects
if projects.any?
errors.add(:cluster, _('cannot have projects assigned'))
errors.add(:cluster, 'cannot have projects assigned')
end
end
end
......
......@@ -188,7 +188,7 @@ module Clusters
def no_namespace
if namespace
errors.add(:namespace, _('only allowed for project cluster'))
errors.add(:namespace, 'only allowed for project cluster')
end
end
......
......@@ -77,6 +77,6 @@ module DiffPositionableNote
def diff_refs_match_commit
return if self.original_position.diff_refs == commit&.diff_refs
errors.add(:commit_id, _('does not match the diff refs'))
errors.add(:commit_id, 'does not match the diff refs')
end
end
......@@ -19,7 +19,7 @@ module HasRepository
def valid_repo?
repository.exists?
rescue
errors.add(:path, _('Invalid repository path'))
errors.add(:base, _('Invalid repository path'))
false
end
......
......@@ -37,7 +37,7 @@ module Milestoneable
private
def milestone_is_valid
errors.add(:milestone_id, _('is invalid')) if respond_to?(:milestone_id) && milestone_id.present? && !milestone_available?
errors.add(:milestone_id, 'is invalid') if respond_to?(:milestone_id) && milestone_id.present? && !milestone_available?
end
end
......
......@@ -77,7 +77,7 @@ module TimeTrackable
return if time_spent.nil? || time_spent == :reset
if time_spent < 0 && (time_spent.abs > original_total_time_spent)
errors.add(:time_spent, _('Time to subtract exceeds the total time spent'))
errors.add(:base, _('Time to subtract exceeds the total time spent'))
end
end
......
......@@ -113,10 +113,10 @@ class DeployToken < ApplicationRecord
end
def no_groups
errors.add(:deploy_token, _('cannot have groups assigned')) if group_deploy_tokens.any?
errors.add(:deploy_token, 'cannot have groups assigned') if group_deploy_tokens.any?
end
def no_projects
errors.add(:deploy_token, _('cannot have projects assigned')) if project_deploy_tokens.any?
errors.add(:deploy_token, 'cannot have projects assigned') if project_deploy_tokens.any?
end
end
......@@ -19,7 +19,13 @@ class DescriptionVersion < ApplicationRecord
def exactly_one_issuable
issuable_count = self.class.issuable_attrs.count { |attr| self["#{attr}_id"] }
errors.add(:base, "Exactly one of #{self.class.issuable_attrs.join(', ')} is required") if issuable_count != 1
if issuable_count != 1
errors.add(
:base,
_("Exactly one of %{attributes} is required") %
{ attributes: self.class.issuable_attrs.join(', ') }
)
end
end
end
......
......@@ -155,13 +155,13 @@ class DiffNote < Note
def verify_supported
return if supported?
errors.add(:noteable, _("doesn't support new-style diff notes"))
errors.add(:noteable, "doesn't support new-style diff notes")
end
def positions_complete
return if self.original_position.complete? && self.position.complete?
errors.add(:position, _("is incomplete"))
errors.add(:position, "is incomplete")
end
def keep_around_commits
......
......@@ -23,7 +23,7 @@ class Email < ApplicationRecord
end
def unique_email
self.errors.add(:email, _('has already been taken')) if User.exists?(email: self.email)
self.errors.add(:email, 'has already been taken') if User.exists?(email: self.email)
end
def accept_pending_invitations!
......
......@@ -217,11 +217,11 @@ module ErrorTracking
return if api_url.blank?
unless api_url_slug(:prefix)
return errors.add(:api_url, _('is invalid'))
return errors.add(:api_url, 'is invalid')
end
unless api_url_slug(:organization)
errors.add(:project, _('is a required field'))
errors.add(:project, 'is a required field')
end
end
end
......
......@@ -23,7 +23,7 @@ module IncidentManagement
def issue_template_exists
return unless issue_template_key.present?
errors.add(:issue_template_key, _('not found')) unless issue_template
errors.add(:issue_template_key, 'not found') unless issue_template
end
def issue_template
......
......@@ -11,6 +11,6 @@ class MilestoneRelease < ApplicationRecord
def same_project_between_milestone_and_release
return if milestone&.project_id == release&.project_id
errors.add(:base, _('does not have the same project as the milestone'))
errors.add(:base, _('Release does not have the same project as the milestone'))
end
end
......@@ -376,7 +376,7 @@ class Namespace < ApplicationRecord
def nesting_level_allowed
if ancestors.count > Group::NUMBER_OF_ANCESTORS_ALLOWED
errors.add(:parent_id, _('has too deep level of nesting'))
errors.add(:parent_id, 'has too deep level of nesting')
end
end
......
......@@ -257,13 +257,13 @@ class PagesDomain < ApplicationRecord
def validate_matching_key
unless has_matching_key?
self.errors.add(:key, _("doesn't match the certificate"))
self.errors.add(:key, "doesn't match the certificate")
end
end
def validate_intermediates
unless has_intermediates?
self.errors.add(:certificate, _('misses intermediates'))
self.errors.add(:certificate, 'misses intermediates')
end
end
......
......@@ -79,7 +79,7 @@ class IrkerService < Service
map_recipients
errors.add(:recipients, _('are all invalid')) if channels.empty?
errors.add(:recipients, 'are all invalid') if channels.empty?
true
end
......
......@@ -69,13 +69,13 @@ class PrometheusAlert < ApplicationRecord
def require_valid_environment_project!
return if project == environment&.project
errors.add(:environment, _('invalid project'))
errors.add(:environment, 'invalid project')
end
def require_valid_metric_project!
return if prometheus_metric&.common?
return if project == prometheus_metric&.project
errors.add(:prometheus_metric, _('invalid project'))
errors.add(:prometheus_metric, 'invalid project')
end
end
......@@ -37,6 +37,9 @@ class ResourceEvent < ApplicationRecord
return true if issuable_count == 1
end
errors.add(:base, "Exactly one of #{self.class.issuable_attrs.join(', ')} is required")
errors.add(
:base, _("Exactly one of %{attributes} is required") %
{ attributes: self.class.issuable_attrs.join(', ') }
)
end
end
......@@ -111,7 +111,10 @@ class SentNotification < ApplicationRecord
note = create_reply('Test', dryrun: true)
unless note.valid?
self.errors.add(:base, "Note parameters are invalid: #{note.errors.full_messages.to_sentence}")
self.errors.add(
:base, _("Note parameters are invalid: %{errors}") %
{ errors: note.errors.full_messages.to_sentence }
)
end
end
......
......@@ -142,7 +142,7 @@ class ApprovalMergeRequestRule < ApplicationRecord
return if approval_project_rule.blank?
return if merge_request.project == approval_project_rule.project
errors.add(:approval_project_rule, _('must be for the same project'))
errors.add(:approval_project_rule, 'must be for the same project')
end
def refresh_license_management_approvals(project_approval_rule)
......
......@@ -89,7 +89,7 @@ module EE
return unless group
unless project.project_group_links.where(group: group).exists?
self.errors.add(:group, _('does not have access to the project'))
self.errors.add(:group, 'does not have access to the project')
end
end
......@@ -97,7 +97,7 @@ module EE
return unless user
unless project.team.member?(user)
self.errors.add(:user, _('is not a member of the project'))
self.errors.add(:user, 'is not a member of the project')
end
end
end
......
......@@ -108,13 +108,13 @@ module DesignManagement
return if id_a == id_b
errors.add(:issue, _('must be the same on design and version'))
errors.add(:issue, 'must be the same on design and version')
end
def design_and_version_have_issue_id
return if [design, version].all? { |obj| obj.try(:issue_id).present? }
errors.add(:issue, _('must be present on both design and version'))
errors.add(:issue, 'must be present on both design and version')
end
end
end
......@@ -281,7 +281,7 @@ module EE
return unless mirror_max_capacity && mirror_capacity_threshold
if mirror_capacity_threshold > mirror_max_capacity
errors.add(:mirror_capacity_threshold, _("Project's mirror capacity threshold can't be higher than it's maximum capacity"))
errors.add(:mirror_capacity_threshold, "Project's mirror capacity threshold can't be higher than it's maximum capacity")
end
end
......
......@@ -20,7 +20,7 @@ module EE
def unique_environment_scope
if clusterable.present? && clusterable.clusters.where(environment_scope: environment_scope).where.not(id: id).exists?
errors.add(:environment_scope, _('cannot add duplicated environment scope'))
errors.add(:environment_scope, 'cannot add duplicated environment scope')
end
end
end
......
......@@ -310,7 +310,7 @@ module EE
return if custom_project_templates_group_id.blank?
return if children.exists?(id: custom_project_templates_group_id)
errors.add(:custom_project_templates_group_id, _('has to be a subgroup of the group'))
errors.add(:custom_project_templates_group_id, 'has to be a subgroup of the group')
end
def billed_group_members
......
......@@ -30,7 +30,7 @@ module EE
def sso_enforcement
unless ::Gitlab::Auth::GroupSaml::MembershipEnforcer.new(group).can_add_user?(user)
errors.add(:user, _('is not linked to a SAML account'))
errors.add(:user, 'is not linked to a SAML account')
end
end
end
......
......@@ -399,7 +399,7 @@ module EE
def validate_plan_name
if defined?(@plan_name) && @plan_name.present? && PLANS.exclude?(@plan_name) # rubocop:disable Gitlab/ModuleWithInstanceVariables
errors.add(:plan, _('is not included in the list'))
errors.add(:plan, 'is not included in the list')
end
end
......@@ -407,7 +407,7 @@ module EE
return if shared_runner_minutes_supported?
if shared_runners_minutes_limit_changed?
errors.add(:shared_runners_minutes_limit, _('is not supported for this namespace'))
errors.add(:shared_runners_minutes_limit, 'is not supported for this namespace')
end
end
......
......@@ -131,13 +131,13 @@ module EE
def cannot_be_admin_and_auditor
if admin? && auditor?
errors.add(:admin, _('user cannot also be an Auditor.'))
errors.add(:admin, 'user cannot also be an Auditor.')
end
end
def auditor_requires_license_add_on
unless license_allows_auditor_user?
errors.add(:auditor, _('user cannot be created without the "GitLab_Auditor_User" addon'))
errors.add(:auditor, 'user cannot be created without the "GitLab_Auditor_User" addon')
end
end
......
......@@ -59,7 +59,7 @@ class IssueLink < ApplicationRecord
return unless source && target
if source == target
errors.add(:source, _('cannot be related to itself'))
errors.add(:source, 'cannot be related to itself')
end
end
end
......@@ -64,7 +64,7 @@ module Operations
def first_default_scope
unless scopes.first.environment_scope == '*'
errors.add(:default_scope, _('has to be the first element'))
errors.add(:default_scope, 'has to be the first element')
end
end
......
......@@ -132,7 +132,7 @@ class Packages::Package < ApplicationRecord
return unless project&.root_namespace
unless name =~ %r{\A@#{project.root_namespace.path}/[^/]+\z}
errors.add(:name, _('is not valid'))
errors.add(:name, 'is not valid')
end
end
......
......@@ -25,7 +25,7 @@ class ServiceDeskSetting < ApplicationRecord
def valid_issue_template
if issue_template_missing?
errors.add(:issue_template_key, _('is empty or does not exist'))
errors.add(:issue_template_key, 'is empty or does not exist')
end
end
end
......@@ -12,14 +12,14 @@ module DraftNotes
def execute
if in_reply_to_discussion_id.present?
unless discussion
return base_error('Thread to reply to cannot be found')
return base_error(_('Thread to reply to cannot be found'))
end
params[:discussion_id] = discussion.reply_id
end
if params[:resolve_discussion] && !can_resolve_discussion?
return base_error('User is not allowed to resolve thread')
return base_error(_('User is not allowed to resolve thread'))
end
draft_note = DraftNote.new(params)
......
......@@ -40,9 +40,6 @@ msgstr ""
msgid " and %{sliced}"
msgstr ""
msgid " cant be 00000000 (branch removal)"
msgstr ""
msgid " degraded on %d point"
msgid_plural " degraded on %d points"
msgstr[0] ""
......@@ -3248,6 +3245,9 @@ msgstr ""
msgid "Cannot modify managed Kubernetes cluster"
msgstr ""
msgid "Cannot modify provider during creation"
msgstr ""
msgid "Cannot refer to a group milestone by an internal id!"
msgstr ""
......@@ -8021,6 +8021,9 @@ msgstr ""
msgid "Evidence collection"
msgstr ""
msgid "Exactly one of %{attributes} is required"
msgstr ""
msgid "Example: @sub\\.company\\.com$"
msgstr ""
......@@ -13153,6 +13156,9 @@ msgstr ""
msgid "Note"
msgstr ""
msgid "Note parameters are invalid: %{errors}"
msgstr ""
msgid "Note that this invitation was sent to %{mail_to_invite_email}, but you are signed in as %{link_to_current_user} with email %{mail_to_current_user}."
msgstr ""
......@@ -15000,9 +15006,6 @@ msgstr ""
msgid "Project visibility level will be changed to match namespace rules when transferring to a group."
msgstr ""
msgid "Project's mirror capacity threshold can't be higher than it's maximum capacity"
msgstr ""
msgid "Project: %{name}"
msgstr ""
......@@ -16058,6 +16061,9 @@ msgid_plural "Releases"
msgstr[0] ""
msgstr[1] ""
msgid "Release does not have the same project as the milestone"
msgstr ""
msgid "Release notes"
msgstr ""
......@@ -20166,6 +20172,9 @@ msgstr ""
msgid "Those emails automatically become issues (with the comments becoming the email conversation) listed here."
msgstr ""
msgid "Thread to reply to cannot be found"
msgstr ""
msgid "Threat Monitoring"
msgstr ""
......@@ -21340,6 +21349,9 @@ msgstr ""
msgid "User identity was successfully updated."
msgstr ""
msgid "User is not allowed to resolve thread"
msgstr ""
msgid "User key was successfully removed."
msgstr ""
......@@ -22649,6 +22661,9 @@ msgstr ""
msgid "You need to register a two-factor authentication app before you can set up a U2F device."
msgstr ""
msgid "You need to set terms to be enforced"
msgstr ""
msgid "You need to specify both an Access Token and a Host URL."
msgstr ""
......@@ -22945,9 +22960,6 @@ msgstr ""
msgid "archived"
msgstr ""
msgid "are all invalid"
msgstr ""
msgid "assign yourself"
msgstr ""
......@@ -22969,12 +22981,6 @@ msgstr ""
msgid "by %{user}"
msgstr ""
msgid "can not be empty when runner is not allowed to pick untagged jobs"
msgstr ""
msgid "cannot add duplicated environment scope"
msgstr ""
msgid "cannot be changed if a personal project has container registry tags."
msgstr ""
......@@ -22984,18 +22990,9 @@ msgstr ""
msgid "cannot be modified"
msgstr ""
msgid "cannot be related to itself"
msgstr ""
msgid "cannot block others"
msgstr ""
msgid "cannot have groups assigned"
msgstr ""
msgid "cannot have projects assigned"
msgstr ""
msgid "cannot include leading slash or directory traversal."
msgstr ""
......@@ -23005,9 +23002,6 @@ msgstr ""
msgid "cannot merge"
msgstr ""
msgid "cannot modify during creation"
msgstr ""
msgid "ciReport|%{linkStartTag}Learn more about Container Scanning %{linkEndTag}"
msgstr ""
......@@ -23271,21 +23265,6 @@ msgstr ""
msgid "does not have a supported extension. Only %{extension_list} are supported"
msgstr ""
msgid "does not have access to the project"
msgstr ""
msgid "does not have the same project as the milestone"
msgstr ""
msgid "does not match the diff refs"
msgstr ""
msgid "doesn't match the certificate"
msgstr ""
msgid "doesn't support new-style diff notes"
msgstr ""
msgid "done"
msgstr ""
......@@ -23389,15 +23368,6 @@ msgstr ""
msgid "has already been taken"
msgstr ""
msgid "has to be a subgroup of the group"
msgstr ""
msgid "has to be the first element"
msgstr ""
msgid "has too deep level of nesting"
msgstr ""
msgid "help"
msgstr ""
......@@ -23433,15 +23403,9 @@ msgstr[1] ""
msgid "invalid milestone state `%{state}`"
msgstr ""
msgid "invalid project"
msgstr ""
msgid "is"
msgstr ""
msgid "is a required field"
msgstr ""
msgid "is already associated to a GitLab Issue. New issue will not be associated."
msgstr ""
......@@ -23451,18 +23415,9 @@ msgstr ""
msgid "is blocked by"
msgstr ""
msgid "is empty or does not exist"
msgstr ""
msgid "is enabled."
msgstr ""
msgid "is incomplete"
msgstr ""
msgid "is invalid"
msgstr ""
msgid "is invalid because there is downstream lock"
msgstr ""
......@@ -23475,9 +23430,6 @@ msgstr ""
msgid "is not a descendant of the Group owning the template"
msgstr ""
msgid "is not a member of the project"
msgstr ""
msgid "is not a valid X509 certificate."
msgstr ""
......@@ -23490,18 +23442,6 @@ msgstr ""
msgid "is not an email you own"
msgstr ""
msgid "is not included in the list"
msgstr ""
msgid "is not linked to a SAML account"
msgstr ""
msgid "is not supported for this namespace"
msgstr ""
msgid "is not valid"
msgstr ""
msgid "is too long (%{current_value}). The maximum size is %{max_size}."
msgstr ""
......@@ -23573,9 +23513,6 @@ msgstr ""
msgid "milestone should belong either to a project or a group."
msgstr ""
msgid "misses intermediates"
msgstr ""
msgid "missing"
msgstr ""
......@@ -23891,27 +23828,12 @@ msgstr ""
msgid "mrWidget|to start a merge train when the pipeline succeeds"
msgstr ""
msgid "must be for the same project"
msgstr ""
msgid "must be greater than start date"
msgstr ""
msgid "must be present on both design and version"
msgstr ""
msgid "must be the same on design and version"
msgstr ""
msgid "n/a"
msgstr ""
msgid "needs to be assigned to at least one project"
msgstr ""
msgid "needs to be assigned to exactly one group"
msgstr ""
msgid "needs to be between 10 minutes and 1 month"
msgstr ""
......@@ -23945,9 +23867,6 @@ msgstr ""
msgid "nounSeries|%{item}, and %{lastItem}"
msgstr ""
msgid "only allowed for project cluster"
msgstr ""
msgid "opened %{timeAgoString} by %{user}"
msgstr ""
......@@ -24170,12 +24089,6 @@ msgstr ""
msgid "user avatar"
msgstr ""
msgid "user cannot also be an Auditor."
msgstr ""
msgid "user cannot be created without the \"GitLab_Auditor_User\" addon"
msgstr ""
msgid "username"
msgstr ""
......
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