Class: Seahorse::ParamValidator Private

Inherits:
Object
  • Object
show all
Defined in:
lib/seahorse/param_validator.rb

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(rules) ⇒ ParamValidator

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of ParamValidator.

Parameters:

  • rules (Hash)


23
24
25
# File 'lib/seahorse/param_validator.rb', line 23

def initialize rules
  @rules = (rules || {})['members'] || {}
end

Class Method Details

.validate!(rules, params) ⇒ Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns ‘true` when params are valid.

Parameters:

  • rules (Hash)
  • params (Hash)

Returns:

  • (Boolean)

    Returns ‘true` when params are valid.

Raises:

  • (ArgumentError)

    Raises an ‘ArgumentError` when one or more of the request parameters are invalid.



151
152
153
# File 'lib/seahorse/param_validator.rb', line 151

def validate! rules, params
  ParamValidator.new(rules).validate!(params)
end

Instance Method Details

#validate!(params) ⇒ Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns ‘true` if the `params` are valid.

Parameters:

  • params (Hash)

    A hash of request params.

Returns:

  • (Boolean)

    Returns ‘true` if the `params` are valid.

Raises:

  • (ArgumentError)

    Raises an ‘ArgumentError` if any of the given request parameters are invalid.



31
32
33
34
# File 'lib/seahorse/param_validator.rb', line 31

def validate! params
  validate_structure(@rules, params || {})
  true
end