Sha256: ac88fd7d1cc30b5d03540d621cc0e2758954d95e60bd559f50b2a11ec4d12c7a

Contents?: true

Size: 906 Bytes

Versions: 2

Compression:

Stored size: 906 Bytes

Contents

module Telegraph
  module Account
    CreateAccountSchema = Dry::Validation.Schema do
      required(:short_name) { str? & size?(1..32) }
      optional(:author_name) { str? & size?(0..128) }
      optional(:author_url) { str? & size?(0..512) }
    end

    EditAccountInfoSchema = Dry::Validation.Schema do
      required(:access_token) { str? }
      optional(:short_name) { str? & size?(1..32) }
      optional(:author_name) { str? & size?(0..128) }
      optional(:author_url) { str? & size?(0..512) }
    end

    GetAccountInfoSchema = Dry::Validation.Schema do
      configure do
        def valid_fields?(value)
          (value - Telegraph::Types::Account::FIELDS).empty?
        end
      end

      required(:access_token) { str? }
      optional(:fields) { valid_fields? }
    end

    RevokeAccessTokenSchema = Dry::Validation.Schema do
      required(:access_token) { str? }
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
telegraph_api-0.1.1 lib/telegraph/validations/account.rb
telegraph_api-0.1.0 lib/telegraph/validations/account.rb