diff options
author | Nick Thomas <nick@gitlab.com> | 2016-12-08 01:09:18 +0000 |
---|---|---|
committer | Nick Thomas <nick@gitlab.com> | 2016-12-15 13:57:03 +0000 |
commit | 93a03cd92f6418fbeaf126c30c161ab40d377e94 (patch) | |
tree | 0f49cd51558b97b8674e72b200e7d9150562e00e /lib/api/helpers | |
parent | 35a3e9183052bab847c30203f27fea9cf77901a4 (diff) | |
download | gitlab-ce-93a03cd92f6418fbeaf126c30c161ab40d377e94.tar.gz |
Add an environment slug
Diffstat (limited to 'lib/api/helpers')
-rw-r--r-- | lib/api/helpers/custom_validators.rb | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/lib/api/helpers/custom_validators.rb b/lib/api/helpers/custom_validators.rb new file mode 100644 index 00000000000..0a8f3073a50 --- /dev/null +++ b/lib/api/helpers/custom_validators.rb @@ -0,0 +1,14 @@ +module API + module Helpers + module CustomValidators + class Absence < Grape::Validations::Base + def validate_param!(attr_name, params) + return if params.respond_to?(:key?) && !params.key?(attr_name) + raise Grape::Exceptions::Validation, params: [@scope.full_name(attr_name)], message: message(:absence) + end + end + end + end +end + +Grape::Validations.register_validator(:absence, ::API::Helpers::CustomValidators::Absence) |