Class: Lutaml::Model::Validator
- Inherits:
-
Services::Base
- Object
- Services::Base
- Lutaml::Model::Validator
- Defined in:
- lib/lutaml/model/services/validator.rb
Instance Attribute Summary collapse
-
#errors ⇒ Object
readonly
Returns the value of attribute errors.
-
#memoization_container ⇒ Object
readonly
Returns the value of attribute memoization_container.
-
#validations ⇒ Object
readonly
Returns the value of attribute validations.
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(value, validations, memoization_container) ⇒ Validator
constructor
A new instance of Validator.
Methods inherited from Services::Base
Constructor Details
#initialize(value, validations, memoization_container) ⇒ Validator
Returns a new instance of Validator.
30 31 32 33 34 35 36 37 38 |
# File 'lib/lutaml/model/services/validator.rb', line 30 def initialize(value, validations, memoization_container) super() @errors = Errors.new @value = value @memoization_container = memoization_container resolve_validations(validations) end |
Instance Attribute Details
#errors ⇒ Object (readonly)
Returns the value of attribute errors.
28 29 30 |
# File 'lib/lutaml/model/services/validator.rb', line 28 def errors @errors end |
#memoization_container ⇒ Object (readonly)
Returns the value of attribute memoization_container.
28 29 30 |
# File 'lib/lutaml/model/services/validator.rb', line 28 def memoization_container @memoization_container end |
#validations ⇒ Object (readonly)
Returns the value of attribute validations.
28 29 30 |
# File 'lib/lutaml/model/services/validator.rb', line 28 def validations @validations end |
#value ⇒ Object (readonly)
Returns the value of attribute value.
28 29 30 |
# File 'lib/lutaml/model/services/validator.rb', line 28 def value @value end |
Instance Method Details
#call ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/lutaml/model/services/validator.rb', line 40 def call return [] if Utils.blank?(validations) @validations.each do |validation| if validation.custom? public_send(validation.custom_method, value) else validation..each do |key, rule| send(:"validate_#{key}", value, validation.attribute, rule) end end end errors. end |