Sha256: f21e67f58d286b3944b6f96c2c71b8e1c0026511499f0ae246114d4edd60b5bb

Contents?: true

Size: 601 Bytes

Versions: 10

Compression:

Stored size: 601 Bytes

Contents

require 'action_logic/errors'
require 'action_logic/action_validation/base_validation'

module ActionLogic
  module ActionValidation
    class AttributeValidation < BaseValidation

      def self.validate!(validation_rules, context)
        existing_attributes = context.to_h.keys
        expected_attributes = validation_rules.keys || []
        missing_attributes  = expected_attributes - existing_attributes

        raise ActionLogic::MissingAttributeError.new(error_message_format(missing_attributes.join(", ") + " attributes are missing")) if missing_attributes.any?
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
action_logic-0.3.3 lib/action_logic/action_validation/attribute_validation.rb
action_logic-0.3.2 lib/action_logic/action_validation/attribute_validation.rb
action_logic-0.3.1 lib/action_logic/action_validation/attribute_validation.rb
action_logic-0.3.0 lib/action_logic/action_validation/attribute_validation.rb
action_logic-0.2.8 lib/action_logic/action_validation/attribute_validation.rb
action_logic-0.2.7 lib/action_logic/action_validation/attribute_validation.rb
action_logic-0.2.6 lib/action_logic/action_validation/attribute_validation.rb
action_logic-0.2.5 lib/action_logic/action_validation/attribute_validation.rb
action_logic-0.2.4 lib/action_logic/action_validation/attribute_validation.rb
action_logic-0.2.3 lib/action_logic/action_validation/attribute_validation.rb