Commit f85a7cbb authored by Marcos Rocha's avatar Marcos Rocha Committed by Terri Chu

Annotate DAST models strings for localization

Changelog: added
MR:
EE: true
parent 7771a207
...@@ -48,24 +48,24 @@ module Dast ...@@ -48,24 +48,24 @@ module Dast
return unless branch_name return unless branch_name
unless project.repository.exists? unless project.repository.exists?
errors.add(:project, 'must have a repository') errors.add(:project, _('must have a repository'))
return return
end end
unless project.repository.branch_exists?(branch_name) unless project.repository.branch_exists?(branch_name)
errors.add(:branch_name, 'can\'t reference a branch that does not exist') errors.add(:branch_name, _('can\'t reference a branch that does not exist'))
end end
end end
def description_not_nil def description_not_nil
errors.add(:description, 'can\'t be nil') if description.nil? errors.add(:description, _('can\'t be nil')) if description.nil?
end end
def association_project_id_matches(association) def association_project_id_matches(association)
return if association.nil? return if association.nil?
unless project_id == association.project_id unless project_id == association.project_id
errors.add(:project_id, "must match #{association.class.underscore}.project_id") errors.add(:project_id, _('must match %{association}.project_id') % { association: association.class.underscore })
end end
end end
end end
......
...@@ -27,7 +27,7 @@ module Dast ...@@ -27,7 +27,7 @@ module Dast
validates :masked, inclusion: { in: [true] } validates :masked, inclusion: { in: [true] }
validates :variable_type, inclusion: { in: ['env_var'] } validates :variable_type, inclusion: { in: ['env_var'] }
validates :key, uniqueness: { scope: :dast_site_profile_id, message: "(%{value}) has already been taken" } validates :key, uniqueness: { scope: :dast_site_profile_id, message: _('(%{value}) has already been taken') }
# Since user input is base64 encoded before being encrypted, we must validate against the encoded length # Since user input is base64 encoded before being encrypted, we must validate against the encoded length
MAX_VALUE_LENGTH = 10_000 MAX_VALUE_LENGTH = 10_000
...@@ -35,7 +35,7 @@ module Dast ...@@ -35,7 +35,7 @@ module Dast
validates :value, length: { validates :value, length: {
maximum: MAX_ENCODED_VALUE_LENGTH, # encoded user input length maximum: MAX_ENCODED_VALUE_LENGTH, # encoded user input length
too_long: -> (object, data) { "exceeds the #{MAX_VALUE_LENGTH} character limit" } # user input length too_long: -> (object, data) { _('exceeds the %{max_value_length} character limit') % { max_value_length: MAX_VALUE_LENGTH } } # user input length
} }
# User input is base64 encoded before being encrypted in order to allow it to be masked by default # User input is base64 encoded before being encrypted in order to allow it to be masked by default
......
...@@ -23,7 +23,7 @@ class DastSite < ApplicationRecord ...@@ -23,7 +23,7 @@ class DastSite < ApplicationRecord
return unless dast_site_validation_id return unless dast_site_validation_id
if project_id != dast_site_validation.project.id if project_id != dast_site_validation.project.id
errors.add(:project_id, 'does not match dast_site_validation.project') errors.add(:project_id, _('does not match dast_site_validation.project'))
end end
end end
end end
...@@ -87,18 +87,18 @@ class DastSiteProfile < ApplicationRecord ...@@ -87,18 +87,18 @@ class DastSiteProfile < ApplicationRecord
def dast_site_project_id_fk def dast_site_project_id_fk
unless project_id == dast_site&.project_id unless project_id == dast_site&.project_id
errors.add(:project_id, 'does not match dast_site.project') errors.add(:project_id, _('does not match dast_site.project'))
end end
end end
def excluded_urls_contains_valid_urls def excluded_urls_contains_valid_urls
validate_excluded_urls_with("contains invalid URLs (%{urls})") do |excluded_url| validate_excluded_urls_with(_("contains invalid URLs (%{urls})")) do |excluded_url|
!Gitlab::UrlSanitizer.valid?(excluded_url) !Gitlab::UrlSanitizer.valid?(excluded_url)
end end
end end
def excluded_urls_contains_valid_strings def excluded_urls_contains_valid_strings
validate_excluded_urls_with("contains URLs that exceed the 1024 character limit (%{urls})") do |excluded_url| validate_excluded_urls_with(_("contains URLs that exceed the 1024 character limit (%{urls})")) do |excluded_url|
excluded_url.length > 1024 excluded_url.length > 1024
end end
end end
......
...@@ -39888,12 +39888,18 @@ msgstr "" ...@@ -39888,12 +39888,18 @@ msgstr ""
msgid "can only have one escalation policy" msgid "can only have one escalation policy"
msgstr "" msgstr ""
msgid "can't be nil"
msgstr ""
msgid "can't be the same as the source project" msgid "can't be the same as the source project"
msgstr "" msgstr ""
msgid "can't include: %{invalid_storages}" msgid "can't include: %{invalid_storages}"
msgstr "" msgstr ""
msgid "can't reference a branch that does not exist"
msgstr ""
msgid "cannot be a date in the past" msgid "cannot be a date in the past"
msgstr "" msgstr ""
...@@ -40269,6 +40275,12 @@ msgstr "" ...@@ -40269,6 +40275,12 @@ msgstr ""
msgid "container_name cannot be larger than %{max_length} chars" msgid "container_name cannot be larger than %{max_length} chars"
msgstr "" msgstr ""
msgid "contains URLs that exceed the 1024 character limit (%{urls})"
msgstr ""
msgid "contains invalid URLs (%{urls})"
msgstr ""
msgid "contribute to this project." msgid "contribute to this project."
msgstr "" msgstr ""
...@@ -40337,6 +40349,12 @@ msgstr "" ...@@ -40337,6 +40349,12 @@ msgstr ""
msgid "does not have a supported extension. Only %{extension_list} are supported" msgid "does not have a supported extension. Only %{extension_list} are supported"
msgstr "" msgstr ""
msgid "does not match dast_site.project"
msgstr ""
msgid "does not match dast_site_validation.project"
msgstr ""
msgid "download it" msgid "download it"
msgstr "" msgstr ""
...@@ -40390,6 +40408,9 @@ msgstr "" ...@@ -40390,6 +40408,9 @@ msgstr ""
msgid "example.com" msgid "example.com"
msgstr "" msgstr ""
msgid "exceeds the %{max_value_length} character limit"
msgstr ""
msgid "exceeds the limit of %{bytes} bytes" msgid "exceeds the limit of %{bytes} bytes"
msgstr "" msgstr ""
...@@ -41068,6 +41089,12 @@ msgstr "" ...@@ -41068,6 +41089,12 @@ msgstr ""
msgid "must be unique by status and elapsed time within a policy" msgid "must be unique by status and elapsed time within a policy"
msgstr "" msgstr ""
msgid "must have a repository"
msgstr ""
msgid "must match %{association}.project_id"
msgstr ""
msgid "my-awesome-group" msgid "my-awesome-group"
msgstr "" 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