Method: ContentfulLite::Validations::Entry.validates_included_asset

Defined in:
lib/contentful_lite/validations/entry.rb

.validates_included_asset(*attr_names, **options) ⇒ Object

Adds a validation on one or more fields to ensure it’s a reference field and the values are assets

Options Hash (**options):

  • :type (Array<Class>)

    the asset content types that will be allowed

  • :allow_blank (Boolean)

    if true it allows the field to be empty

  • :array (Boolean)

    if true, the field must be an array of references. If not, it must be a single reference.



47
48
49
50
51
# File 'lib/contentful_lite/validations/entry.rb', line 47

class_methods do
  def validates_included_asset(*attr_names)
    validates_with IncludedAssetValidator, _merge_attributes(attr_names)
  end
end