Class: Fortnox::API::Validator::Base
- Inherits:
-
Object
- Object
- Fortnox::API::Validator::Base
show all
- Includes:
- Mixin
- Defined in:
- lib/fortnox/api/validators/base.rb
Instance Method Summary
collapse
Methods included from Mixin
included
Instance Method Details
#instance ⇒ Object
50
51
52
53
54
|
# File 'lib/fortnox/api/validators/base.rb', line 50
def instance
raise_error_if_no_validator
self
end
|
#validate(instance) ⇒ Object
30
31
32
33
34
35
36
37
38
39
40
41
42
|
# File 'lib/fortnox/api/validators/base.rb', line 30
def validate( instance )
raise_error_if_no_validator
valid = true
validators.each do |validator|
validation_result = validator.call( instance )
violations.merge( validation_result.violations )
valid = valid && validation_result.valid?
end
return valid
end
|
#violations ⇒ Object
44
45
46
47
48
|
# File 'lib/fortnox/api/validators/base.rb', line 44
def violations
raise_error_if_no_validator
@violations ||= Set.new
end
|