Sha256: 70468cc62b9d0191714c49e3857c970e9913500077a0e7026c78db1dfdaa33dd

Contents?: true

Size: 840 Bytes

Versions: 27

Compression:

Stored size: 840 Bytes

Contents

module Foobara
  module TypeDeclarations
    module Handlers
      class ExtendEntityTypeDeclaration < ExtendModelTypeDeclaration
        class ValidatePrimaryKeyPresent < TypeDeclarations::TypeDeclarationValidator
          # TODO: seems like maybe we could actually check against types now...
          # like make a type for primary_key: :symbol ??
          class MissingPrimaryKeyError < TypeDeclarationError; end

          def validation_errors(strict_type_declaration)
            unless strict_type_declaration.key?(:primary_key)
              build_error
            end
          end

          def error_message(_value)
            "Missing required :primary_key to state which attribute is the primary key"
          end

          def error_context(_value)
            {}
          end
        end
      end
    end
  end
end

Version data entries

27 entries across 27 versions & 1 rubygems

Version Path
foobara-0.0.7 projects/entity/src/extensions/type_declarations/handlers/extend_entity_type_declaration/validate_primary_key_present.rb
foobara-0.0.6 projects/entity/src/extensions/type_declarations/handlers/extend_entity_type_declaration/validate_primary_key_present.rb
foobara-0.0.5 projects/entity/src/extensions/type_declarations/handlers/extend_entity_type_declaration/validate_primary_key_present.rb
foobara-0.0.4 projects/entity/src/extensions/type_declarations/handlers/extend_entity_type_declaration/validate_primary_key_present.rb
foobara-0.0.3 projects/entity/src/extensions/type_declarations/handlers/extend_entity_type_declaration/validate_primary_key_present.rb
foobara-0.0.2 projects/entity/src/extensions/type_declarations/handlers/extend_entity_type_declaration/validate_primary_key_present.rb
foobara-0.0.1 projects/entity/src/extensions/type_declarations/handlers/extend_entity_type_declaration/validate_primary_key_present.rb