Module: IcingaCertService::Validator
- Included in:
- Client
- Defined in:
- lib/validator.rb
Overview
namespace for validate options
Instance Method Summary collapse
-
#validate(params, options) ⇒ Mixed
function to validate function parameters.
Instance Method Details
#validate(params, options) ⇒ Mixed
function to validate function parameters
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/validator.rb', line 21 def validate( params, ) required = .dig(:required) || false var = .dig(:var) type = .dig(:type) params = params.deep_symbolize_keys variable = params.dig(var.to_sym) clazz = Object.const_get(type.to_s) raise ArgumentError.new(format('\'%s\' is requiered and missing!', var)) if(variable.nil?) if(required == true ) raise ArgumentError.new(format('wrong type. \'%s\' must be an %s, given \'%s\'', var, type, variable.class.to_s)) unless( variable.nil? || variable.is_a?(clazz) ) variable end |