diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-11-18 16:16:36 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-11-18 16:16:36 +0300 |
commit | 311b0269b4eb9839fa63f80c8d7a58f32b8138a0 (patch) | |
tree | 07e7870bca8aed6d61fdcc810731c50d2c40af47 /app/validators | |
parent | 27909cef6c4170ed9205afa7426b8d3de47cbb0c (diff) |
Add latest changes from gitlab-org/gitlab@14-5-stable-eev14.5.0-rc42
Diffstat (limited to 'app/validators')
-rw-r--r-- | app/validators/gitlab/emoji_name_validator.rb | 19 | ||||
-rw-r--r-- | app/validators/json_schemas/error_tracking_event_payload.json | 13 | ||||
-rw-r--r-- | app/validators/json_schemas/helm_metadata.json | 18 | ||||
-rw-r--r-- | app/validators/json_schemas/npm_package_json.json | 26 |
4 files changed, 64 insertions, 12 deletions
diff --git a/app/validators/gitlab/emoji_name_validator.rb b/app/validators/gitlab/emoji_name_validator.rb new file mode 100644 index 00000000000..a9092d0194f --- /dev/null +++ b/app/validators/gitlab/emoji_name_validator.rb @@ -0,0 +1,19 @@ +# frozen_string_literal: true + +# Gitlab::EmojiNameValidator +# +# Validates that the provided value matches an indexed emoji alpha code +# +# @example Usage +# class AwardEmoji < ApplicationRecord +# validate :name, 'gitlab/emoji_name': true +# end +module Gitlab + class EmojiNameValidator < ActiveModel::EachValidator + def validate_each(record, attribute, value) + unless TanukiEmoji.find_by_alpha_code(value.to_s) + record.errors.add(attribute, (options[:message] || 'is not a valid emoji name')) + end + end + end +end diff --git a/app/validators/json_schemas/error_tracking_event_payload.json b/app/validators/json_schemas/error_tracking_event_payload.json index 52efcf6800c..73ff71043ce 100644 --- a/app/validators/json_schemas/error_tracking_event_payload.json +++ b/app/validators/json_schemas/error_tracking_event_payload.json @@ -1,7 +1,7 @@ { "description": "Error tracking event payload", "type": "object", - "required": [], + "required": ["exception"], "properties": { "environment": { "type": "string" @@ -14,7 +14,7 @@ }, "exception": { "type": "object", - "required": [], + "required": ["values"], "properties": { "values": { "type": "array", @@ -28,12 +28,6 @@ "value": { "type": "string" }, - "module": { - "type": "string" - }, - "thread_id": { - "type": "number" - }, "stacktrace": { "type": "object", "required": [], @@ -44,9 +38,6 @@ "type": "object", "required": [], "properties": { - "project_root": { - "type": "string" - }, "abs_path": { "type": "string" }, diff --git a/app/validators/json_schemas/helm_metadata.json b/app/validators/json_schemas/helm_metadata.json index 7ac36e956f3..a5ff6f0b33a 100644 --- a/app/validators/json_schemas/helm_metadata.json +++ b/app/validators/json_schemas/helm_metadata.json @@ -103,7 +103,23 @@ "import-values": { "type": "array", "items": { - + "oneOf": [ + { + "type": "string" + }, + { + "type": "object", + "properties": { + "child": { + "type": "string" + }, + "parent": { + "type": "string" + } + }, + "additionalProperties": false + } + ] } }, "alias": { diff --git a/app/validators/json_schemas/npm_package_json.json b/app/validators/json_schemas/npm_package_json.json new file mode 100644 index 00000000000..01bd874d214 --- /dev/null +++ b/app/validators/json_schemas/npm_package_json.json @@ -0,0 +1,26 @@ +{ + "description": "NPM package json metadata", + "type": "object", + "properties": { + "name": { "type": "string" }, + "version": { "type": "string" }, + "dist": { + "type": "object", + "properties": { + "tarball": { "type": "string" }, + "shasum": { "type": "string" } + }, + "additionalProperties": true, + "required": [ + "tarball", + "shasum" + ] + } + }, + "additionalProperties": true, + "required": [ + "name", + "version", + "dist" + ] +} |