Module: ContentfulLite::Validations::Entry
- Extended by:
- ActiveSupport::Concern
- Included in:
- Entry
- Defined in:
- lib/contentful_lite/validations/entry.rb
Class Method Summary collapse
-
.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.
-
.validates_included_entry(*attr_names, **options) ⇒ Object
Adds a validation on one or more fields to ensure it’s a reference field and the values are entries with one of the specified types.
Instance Method Summary collapse
-
#errors_for_all_locales ⇒ Hash
Gets the error messages for all the locales at once.
-
#valid_for_all_locales? ⇒ boolean
Validates all locales.
Class Method Details
.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
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 |
.validates_included_entry(*attr_names, **options) ⇒ Object
Adds a validation on one or more fields to ensure it’s a reference field and the values are entries with one of the specified types
32 33 34 35 36 |
# File 'lib/contentful_lite/validations/entry.rb', line 32 class_methods do def validates_included_entry(*attr_names) validates_with IncludedEntryValidator, _merge_attributes(attr_names) end end |
Instance Method Details
#errors_for_all_locales ⇒ Hash
Gets the error messages for all the locales at once
63 64 65 |
# File 'lib/contentful_lite/validations/entry.rb', line 63 def errors_for_all_locales @errors end |
#valid_for_all_locales? ⇒ boolean
Validates all locales
55 56 57 58 59 |
# File 'lib/contentful_lite/validations/entry.rb', line 55 def valid_for_all_locales? locales.map do |locale| valid?(locale: locale) end.all? end |