Class: Validator

Inherits:
Kimurai::Pipeline show all
Defined in:
lib/kimurai/template/pipelines/validator.rb

Instance Attribute Summary

Attributes inherited from Kimurai::Pipeline

#spider

Instance Method Summary collapse

Methods inherited from Kimurai::Pipeline

#logger, #name, name, #save_to, #storage, #unique?

Instance Method Details

#process_item(item, options: {}) ⇒ Object



2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/kimurai/template/pipelines/validator.rb', line 2

def process_item(item, options: {})
  # Here you can validate item and raise `DropItemError`
  # if one of the validations failed. Examples:

  # Check item sku for uniqueness using buit-in `unique?` helper:
  # unless unique?(:sku, item[:sku])
  #   raise DropItemError, "Item sku is not unique"
  # end

  # Drop item if title length shorter than 5 symbols:
  # if item[:title].size < 5
  #   raise DropItemError, "Item title is short"
  # end

  # Drop item if it doesn't contains any images:
  # unless item[:images].present?
  #   raise DropItemError, "Item images are not present"
  # end

  # Pass item to the next pipeline (if it wasn't dropped)
  item
end