Class: Wallaby::ActiveRecord::ModelServiceProvider::Validator
- Inherits:
-
Object
- Object
- Wallaby::ActiveRecord::ModelServiceProvider::Validator
- Defined in:
- lib/adapters/wallaby/active_record/model_service_provider/validator.rb
Overview
Validate values for record create / update
Instance Method Summary collapse
-
#initialize(model_decorator) ⇒ Validator
constructor
A new instance of Validator.
- #valid?(resource) ⇒ true, false
Constructor Details
#initialize(model_decorator) ⇒ Validator
Returns a new instance of Validator.
9 10 11 |
# File 'lib/adapters/wallaby/active_record/model_service_provider/validator.rb', line 9 def initialize(model_decorator) @model_decorator = model_decorator end |
Instance Method Details
#valid?(resource) ⇒ true, false
16 17 18 19 20 21 22 23 24 |
# File 'lib/adapters/wallaby/active_record/model_service_provider/validator.rb', line 16 def valid?(resource) resource.attributes.each do |field_name, values| = @model_decorator.fields[field_name] next if valid_range_type? values, resource.errors.add field_name, 'required for range data' end resource.errors.blank? end |