Sha256: b2b95fd08a47a7ad00c6c3b9daedd8aaad39867efb372fa6588e07ef5701fab0

Contents?: true

Size: 925 Bytes

Versions: 10

Compression:

Stored size: 925 Bytes

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

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

10 entries across 10 versions & 1 rubygems

Version Path
contentful-management-1.7.0 lib/contentful/management/validation.rb
contentful-management-1.6.0 lib/contentful/management/validation.rb
contentful-management-1.5.0 lib/contentful/management/validation.rb
contentful-management-1.4.0 lib/contentful/management/validation.rb
contentful-management-1.3.0 lib/contentful/management/validation.rb
contentful-management-1.2.0 lib/contentful/management/validation.rb
contentful-management-1.1.0 lib/contentful/management/validation.rb
contentful-management-1.0.1 lib/contentful/management/validation.rb
contentful-management-1.0.0 lib/contentful/management/validation.rb
contentful-management-0.9.0 lib/contentful/management/validation.rb