Sha256: f2ef37d9ad410b614a1029a5b9ed0204ab5a467cf112a3d3e0fe099ea2e5875b

Contents?: true

Size: 1.09 KB

Versions: 3

Compression:

Stored size: 1.09 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 :range, :hash
      property :regexp, :hash
      property :unique, :boolean
      property :present, :boolean
      property :linkField, :boolean
      property :assetFileSize, :hash
      property :linkContentType, :array
      property :linkMimetypeGroup, :string
      property :assetImageDimensions, :hash
      property :enabledNodeTypes, :array
      property :enabledMarks, :array

      # @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

3 entries across 3 versions & 1 rubygems

Version Path
contentful-management-2.10.0 lib/contentful/management/validation.rb
contentful-management-2.9.1 lib/contentful/management/validation.rb
contentful-management-2.9.0 lib/contentful/management/validation.rb