Class: ContentfulLite::Validations::IncludedAssetValidator Private

Inherits:
ActiveModel::EachValidator
  • Object
show all
Includes:
IncludedChildValidator
Defined in:
lib/contentful_lite/validations/included_asset_validator.rb

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Constant Summary

Constants included from IncludedChildValidator

ContentfulLite::Validations::IncludedChildValidator::BASE_OPTIONS

Instance Method Summary collapse

Methods included from IncludedChildValidator

#validate_each

Instance Method Details

#validate_child(record, attr_name, value, idx = nil) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



8
9
10
11
# File 'lib/contentful_lite/validations/included_asset_validator.rb', line 8

def validate_child(record, attr_name, value, idx = nil)
  record_error(record, attr_name, "value#{idx} is not a published asset") && return unless value.is_a?(ContentfulLite::Asset)
  record_error(record, attr_name, "value#{idx} has an invalid asset type. Expecting #{options[:type]}") if options[:type] && !value&.content_type&.include?(options[:type].to_s)
end