Sha256: 0208b167978967e679acea68a6fcb1e5802c40e13f69ca2e6e0aef76f916bd31

Contents?: true

Size: 1.27 KB

Versions: 2

Compression:

Stored size: 1.27 KB

Contents

module Telegraph
  module Page
    class CommonPageSchema < Dry::Validation::Schema
      define! do
        required(:access_token) { str? & filled? }
        required(:title) { str? & min_size?(1) & max_size?(256) }
        optional(:author_name) { str? & max_size?(128) }
        optional(:author_url) { str? & max_size?(512) }
        required(:content) { str? & filled? & max_size?(64 * 1024 * 1024) }
        optional(:return_content) { bool? }
      end
    end

    CreatePageSchema = Dry::Validation.Schema(CommonPageSchema)

    EditPageSchema = Dry::Validation.Schema(CommonPageSchema) do
      required(:path) { str? & filled? }
    end

    GetPageSchema = Dry::Validation.Schema do
      required(:path) { str? & filled? }
      optional(:return_content) { bool? }
    end

    GetPageListSchema = Dry::Validation.Schema do
      required(:access_token) { str? & filled? }
      optional(:offset) { int? }
      optional(:limit) { int? & size?(0..200) }
    end

    GetViewsSchema = Dry::Validation.Schema do
      required(:path) { str? & filled? }
      required(:year) { int? & included_in?(2000..2100) }
      required(:month) { int? & included_in?(1..12) }
      optional(:day) { int? & included_in?(1..31) }
      optional(:hour) { int? & included_in?(0..24) }
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

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