Class: Releaf::Content::Node::ParentValidator
- Inherits:
-
ActiveModel::Validator
- Object
- ActiveModel::Validator
- Releaf::Content::Node::ParentValidator
- Defined in:
- app/validators/releaf/content/node/parent_validator.rb
Overview
Validator to test if node is valid, when created under given parrent node
validator needs :for and :under options, both can be either array of classes or single class.
:for option specifies for which nodes validation should be applied
:under option specifies under which nodes given node can be added
Instance Method Summary collapse
Instance Method Details
#validate(node) ⇒ Object
21 22 23 24 25 |
# File 'app/validators/releaf/content/node/parent_validator.rb', line 21 def validate node @node = node node.errors.add(:content_type, 'invalid parent node') unless node_parent_valid? remove_instance_variable(:@node) end |