summaryrefslogtreecommitdiff
path: root/lib/api/helpers
diff options
context:
space:
mode:
authorRegis <boudinot.regis@yahoo.com>2016-12-16 09:50:23 -0700
committerRegis <boudinot.regis@yahoo.com>2016-12-16 09:50:23 -0700
commit211ee4b97c0754f30ff018d9a333e72559661a05 (patch)
treec97c0c517ca205d30629d337669a9870ca7752ed /lib/api/helpers
parent27a4aef5848d36b38c861c952a098f85562a31df (diff)
parentae71032d0af1730c359089f3edc9029a8b5c8acc (diff)
downloadgitlab-ce-211ee4b97c0754f30ff018d9a333e72559661a05.tar.gz
Merge branch 'master' into auto-pipelines-vue
Diffstat (limited to 'lib/api/helpers')
-rw-r--r--lib/api/helpers/custom_validators.rb14
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)