Module: Tiktok::Open::Sdk::Helpers::Validators::PostInfoValidator

Included in:
PostPublishValidator
Defined in:
lib/tiktok/open/sdk/helpers/validators/post_info_validator.rb

Overview

Validates post information for TikTok video publishing.

This module provides validation methods for post-related parameters including privacy level, title, boolean flags, and video cover timestamp.

Examples:

Including the validator in a class

class VideoPublisher
  include Tiktok::Open::Sdk::Helpers::Validators::PostInfoValidator

  def publish()
    ()
    # proceed with publishing
  end
end

Validating post information

 = {
  privacy_level: 'PUBLIC_TO_EVERYONE',
  title: 'My awesome video',
  disable_duet: false,
  brand_content_toggle: true
}
()

Constant Summary collapse

PRIVACY_LEVEL_OPTIONS =

Valid privacy level options for TikTok videos

%w[
  PUBLIC_TO_EVERYONE
  MUTUAL_FOLLOW_FRIENDS
  FOLLOWER_OF_CREATOR
  SELF_ONLY
].freeze
MAX_TITLE_LENGTH =

Maximum allowed length for video title

2200

Instance Method Summary collapse

Instance Method Details

#validate_post_info!(post_info) ⇒ void

This method returns an undefined value.

Validates post information and raises an error if invalid.

Examples:

Valid post information

(privacy_level: 'PUBLIC_TO_EVERYONE')

Invalid privacy level

(privacy_level: 'INVALID')
# => raises RequestValidationError with privacy_level error

Parameters:

  • post_info (Hash, nil)

    The post information to validate

Options Hash (post_info):

  • :privacy_level (String)

    Required. Must be one of PRIVACY_LEVEL_OPTIONS

  • :title (String)

    Optional. Maximum 2200 characters

  • :disable_duet (Boolean)

    Optional. Boolean flag

  • :disable_stitch (Boolean)

    Optional. Boolean flag

  • :disable_comment (Boolean)

    Optional. Boolean flag

  • :brand_content_toggle (Boolean)

    Optional. Boolean flag

  • :brand_organic_toggle (Boolean)

    Optional. Boolean flag

  • :is_aigc (Boolean)

    Optional. Boolean flag

  • :video_cover_timestamp_ms (Integer)

    Optional. Non-negative integer

Raises:



65
66
67
68
69
70
71
# File 'lib/tiktok/open/sdk/helpers/validators/post_info_validator.rb', line 65

def ()
  errors = {}

  (, errors)

  raise_validation_errors!(errors)
end