Class: Contentful::Management::Validation

Inherits:
Object
  • Object
show all
Includes:
Resource
Defined in:
lib/contentful/management/validation.rb

Overview

A ContentType’s validations schema

Constant Summary

Constants included from Resource

Resource::COERCIONS

Instance Attribute Summary

Attributes included from Resource

#client, #default_locale, #properties, #raw_object, #request

Instance Method Summary collapse

Methods included from Resource

#array?, #fields, #initialize, #inspect, #nested_locale_fields?, #sys

Instance Method Details

#properties_to_hashObject



18
19
20
21
22
# File 'lib/contentful/management/validation.rb', line 18

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

#typeObject

Returns type of validation



25
26
27
28
29
30
# File 'lib/contentful/management/validation.rb', line 25

def type
  properties.keys.reject { |key| key == :validations }.each do |type|
    value = self.send(Support.snakify(type))
    return type if !value.nil? && value
  end
end