Class: Webhookdb::Service::Validators::DbIdentifier

Inherits:
Grape::Validations::Validators::Base
  • Object
show all
Defined in:
lib/webhookdb/service/validators.rb

Instance Method Summary collapse

Instance Method Details

#validate_param!(attr_name, params) ⇒ Object

Raises:

  • (Grape::Exceptions::Validation)


20
21
22
23
24
25
26
27
28
29
# File 'lib/webhookdb/service/validators.rb', line 20

def validate_param!(attr_name, params)
  val = params[attr_name]
  return if val.blank? && @allow_blank
  return if Webhookdb::DBAdapter.valid_identifier?(val)
  raise Grape::Exceptions::Validation.new(
    params: [@scope.full_name(attr_name)],
    message: "is not a valid database identifier for WebhookDB. " +
      Webhookdb::DBAdapter::INVALID_IDENTIFIER_MESSAGE,
  )
end