Sha256: 40d60435f9e180714be065174f642e04c3e4e85bbea52024ec91245a437fd1bf

Contents?: true

Size: 859 Bytes

Versions: 9

Compression:

Stored size: 859 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 :validations, Validation
      property :regexp, :hash
      property :linkContentType, :array
      property :range, :hash
      property :linkMimetypeGroup, :string
      property :linkField, :boolean

      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
      def type
        properties.keys.each do |type|
          return type if !self.send(Support.snakify(type)).nil?
        end
      end

    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
contentful-management-0.7.1 lib/contentful/management/validation.rb
contentful-management-0.7.0 lib/contentful/management/validation.rb
contentful-management-0.6.1 lib/contentful/management/validation.rb
contentful-management-0.6.0 lib/contentful/management/validation.rb
contentful-management-0.5.0 lib/contentful/management/validation.rb
contentful-management-0.4.1 lib/contentful/management/validation.rb
contentful-management-0.4.0 lib/contentful/management/validation.rb
contentful-management-0.3.1 lib/contentful/management/validation.rb
contentful-management-0.3.0 lib/contentful/management/validation.rb