Class: Kumi::Core::Input::Validator
- Inherits:
-
Object
- Object
- Kumi::Core::Input::Validator
- Defined in:
- lib/kumi/core/input/validator.rb
Class Method Summary collapse
- .format_type(type) ⇒ Object
- .infer_type(value) ⇒ Object
- .type_matches?(value, declared_type) ⇒ Boolean
- .validate_context(context, input_meta) ⇒ Object
Class Method Details
.format_type(type) ⇒ Object
37 38 39 |
# File 'lib/kumi/core/input/validator.rb', line 37 def self.format_type(type) TypeMatcher.format_type(type) end |
.infer_type(value) ⇒ Object
33 34 35 |
# File 'lib/kumi/core/input/validator.rb', line 33 def self.infer_type(value) TypeMatcher.infer_type(value) end |
.type_matches?(value, declared_type) ⇒ Boolean
29 30 31 |
# File 'lib/kumi/core/input/validator.rb', line 29 def self.type_matches?(value, declared_type) TypeMatcher.matches?(value, declared_type) end |
.validate_context(context, input_meta) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/kumi/core/input/validator.rb', line 7 def self.validate_context(context, ) violations = [] context.each do |field, value| = [field] next unless # Type validation first if should_validate_type?() && !TypeMatcher.matches?(value, [:type]) violations << ViolationCreator.create_type_violation(field, value, [:type]) next # Skip domain validation if type is wrong end # Domain validation second (only if type is correct) if should_validate_domain?() && !Domain::Validator.validate_field(field, value, [:domain]) violations << ViolationCreator.create_domain_violation(field, value, [:domain]) end end violations end |