Sha256: 3d4818ff20dc2b30786a6e0cb43ad5a700211c4b2fafe6c8d49df75026b40e2f

Contents?: true

Size: 722 Bytes

Versions: 2

Compression:

Stored size: 722 Bytes

Contents

require 'dry-types'

class PgExport
  module Roles
    module Validatable
      include Dry::Types.module

      VALID_NON_EMPTY_STRING = Strict::String.constrained(min_size: 1)
      VALID_POSITIVE_INTEGER = Strict::Int.constrained(gteq: 0)

      def validate_database_name(database)
        VALID_NON_EMPTY_STRING[database]
      rescue Dry::Types::ConstraintError
        raise ArgumentError, 'The "database" parameter has to be a valid, non-empty string'
      end

      def validate_keep_dumps(keep_dumps)
        VALID_POSITIVE_INTEGER[keep_dumps]
      rescue Dry::Types::ConstraintError
        raise ArgumentError, 'The "keep_dumps" parameter has to be a valid, non-negative integer'
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
pg_export-0.6.1 lib/pg_export/roles/validatable.rb
pg_export-0.6.0 lib/pg_export/roles/validatable.rb