Class: Grape::Validations::RegexpValidator

Inherits:
SingleOptionValidator show all
Defined in:
lib/grape/validations/regexp.rb

Instance Attribute Summary

Attributes inherited from Validator

#attrs

Instance Method Summary (collapse)

Methods inherited from SingleOptionValidator

#initialize

Methods inherited from Validator

inherited, #initialize, #validate!

Constructor Details

This class inherits a constructor from Grape::Validations::SingleOptionValidator

Instance Method Details

- (Object) validate_param!(attr_name, params)



4
5
6
7
8
# File 'lib/grape/validations/regexp.rb', line 4

def validate_param!(attr_name, params)
  if params[attr_name] && !(params[attr_name].to_s =~ @option)
    raise Grape::Exceptions::Validation, param: @scope.full_name(attr_name), message_key: :regexp
  end
end