Sha256: 5b187c8a7d7baa745f9db2463373985ae388aa66d672f9b5f0c3e5c79f778084

Contents?: true

Size: 1.01 KB

Versions: 16

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 :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

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

16 entries across 16 versions & 1 rubygems

Version Path
contentful-management-2.8.2 lib/contentful/management/validation.rb
contentful-management-2.8.1 lib/contentful/management/validation.rb
contentful-management-2.8.0 lib/contentful/management/validation.rb
contentful-management-2.7.0 lib/contentful/management/validation.rb
contentful-management-2.6.0 lib/contentful/management/validation.rb
contentful-management-2.5.0 lib/contentful/management/validation.rb
contentful-management-2.4.0 lib/contentful/management/validation.rb
contentful-management-2.3.0 lib/contentful/management/validation.rb
contentful-management-2.2.2 lib/contentful/management/validation.rb
contentful-management-2.2.1 lib/contentful/management/validation.rb
contentful-management-2.2.0 lib/contentful/management/validation.rb
contentful-management-2.1.1 lib/contentful/management/validation.rb
contentful-management-2.1.0 lib/contentful/management/validation.rb
contentful-management-2.0.2 lib/contentful/management/validation.rb
contentful-management-2.0.1 lib/contentful/management/validation.rb
contentful-management-2.0.0 lib/contentful/management/validation.rb