Class: RivetCms::ContentValidator
- Inherits:
-
Object
- Object
- RivetCms::ContentValidator
- Defined in:
- app/services/rivet_cms/content_validator.rb
Defined Under Namespace
Classes: Error
Instance Attribute Summary collapse
-
#errors ⇒ Object
readonly
Returns the value of attribute errors.
Instance Method Summary collapse
-
#initialize(revision) ⇒ ContentValidator
constructor
A new instance of ContentValidator.
- #messages ⇒ Object
- #valid? ⇒ Boolean
- #validate ⇒ Object
Constructor Details
#initialize(revision) ⇒ ContentValidator
Returns a new instance of ContentValidator.
7 8 9 10 |
# File 'app/services/rivet_cms/content_validator.rb', line 7 def initialize(revision) @revision = revision @errors = [] end |
Instance Attribute Details
#errors ⇒ Object (readonly)
Returns the value of attribute errors.
5 6 7 |
# File 'app/services/rivet_cms/content_validator.rb', line 5 def errors @errors end |
Instance Method Details
#messages ⇒ Object
24 25 26 |
# File 'app/services/rivet_cms/content_validator.rb', line 24 def @errors.map { |e| "#{e.field_key} #{e.}" } end |
#valid? ⇒ Boolean
12 13 14 |
# File 'app/services/rivet_cms/content_validator.rb', line 12 def valid? @errors.empty? end |
#validate ⇒ Object
16 17 18 19 20 21 22 |
# File 'app/services/rivet_cms/content_validator.rb', line 16 def validate raise TrashedEntryError, "entry is in the trash; restore it before validating" if @revision.document.nil? raise RemovedContentTypeError, "content type was removed; restore it before validating" if content_type.nil? validate_owner(@revision, content_type.fields.kept) self end |