Class: Sekisyo::Validator

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/sekisyo/validator.rb

Overview

Sekisyo Validator is manages each validator in one place.

Constant Summary collapse

VALIDATORS =
{
  'any' => Sekisyo::Validators::AnyValidator,
  'array' => Sekisyo::Validators::ArrayValidator,
  'boolean' => Sekisyo::Validators::BooleanValidator,
  'file' => Sekisyo::Validators::FileValidator,
  'float' => Sekisyo::Validators::FloatValidator,
  'integer' => Sekisyo::Validators::IntegerValidator,
  'numeric' => Sekisyo::Validators::NumericValidator,
  'object' => Sekisyo::Validators::ObjectValidator,
  'string' => Sekisyo::Validators::StringValidator
}.freeze

Instance Method Summary collapse

Constructor Details

#initialize(key, options = {}) ⇒ Validator

Returns a new instance of Validator.



33
34
35
36
37
# File 'lib/sekisyo/validator.rb', line 33

def initialize(key, options = {})
  validator_class = VALIDATORS[options.delete('type')]
  validator_class ||= Sekisyo::Validators::AnyValidator
  @validator = validator_class.new(key, options)
end