Sha256: d08a8dea6fc21de5e34fdb02140b8e3d7d2ffafc37a7afa7c158b3a14b346462

Contents?: true

Size: 1.01 KB

Versions: 4

Compression:

Stored size: 1.01 KB

Contents

require_relative 'resource'

module Contentful
  module Management
    # A ContentType's validations schema
    class Validation
      include Contentful::Management::Resource

      property :in, :array
      property :size, :hash
      property :present, :boolean
      property :regexp, :hash
      property :linkContentType, :array
      property :range, :hash
      property :linkMimetypeGroup, :string
      property :linkField, :boolean
      property :unique, :boolean
      property :assetFileSize, :hash
      property :assetImageDimensions, :hash

      # @private
      def properties_to_hash
        properties.each_with_object({}) do |(key, value), results|
          results[key] = value if Field.value_exists?(value)
        end
      end

      # Returns type of validation
      # @return [Symbol]
      def type
        properties.keys.reject { |key| key == :validations }.each do |type|
          value = send(Support.snakify(type))
          return type if !value.nil? && value
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
contentful-management-1.10.1 lib/contentful/management/validation.rb
contentful-management-1.10.0 lib/contentful/management/validation.rb
contentful-management-1.9.0 lib/contentful/management/validation.rb
contentful-management-1.8.1 lib/contentful/management/validation.rb