Module: Kybus::Nanoservice::Validator
- Extended by:
- DRY::ResourceInjector
- Defined in:
- lib/kybus/nanoservice/validator.rb
Overview
This module is a singleton that stores all the validator plugins A validator plugin is introduced into metatypes and used to validate that types are properly validated. See more on the validators documentations.
Class Method Summary collapse
- .register_plugin(name) ⇒ Object
- .register_type(type) ⇒ Object
- .type_alias(type, new_name) ⇒ Object
- .validator(name) ⇒ Object
- .validator_alias(name, new_name) ⇒ Object
Class Method Details
.register_plugin(name) ⇒ Object
13 14 15 16 17 18 |
# File 'lib/kybus/nanoservice/validator.rb', line 13 def self.register_plugin(name) block = lambda do |value, conf| yield(value, conf) ? nil : "#{name} failed!" end register(:validators, name, block) end |
.register_type(type) ⇒ Object
25 26 27 28 |
# File 'lib/kybus/nanoservice/validator.rb', line 25 def self.register_type(type) block = proc { |value| yield(value) } register(:types, type, block) end |
.type_alias(type, new_name) ⇒ Object
30 31 32 33 |
# File 'lib/kybus/nanoservice/validator.rb', line 30 def self.type_alias(type, new_name) validator = resource(:types, type) register(:types, new_name, validator) end |
.validator(name) ⇒ Object
35 36 37 |
# File 'lib/kybus/nanoservice/validator.rb', line 35 def self.validator(name) resource(:validators, name) end |
.validator_alias(name, new_name) ⇒ Object
20 21 22 23 |
# File 'lib/kybus/nanoservice/validator.rb', line 20 def self.validator_alias(name, new_name) validator = resource(:validators, name) register(:validators, new_name, validator) end |