Class: QiitaMatome::Validators::ArticleValidator

Inherits:
Object
  • Object
show all
Defined in:
lib/validators/article_validator.rb

Overview

ArticleValidator

Constant Summary collapse

ARTICLE_CLASS_ERROR =
"invalid argument class '%s'.article must be Array"

Class Method Summary collapse

Class Method Details

.validate(articles) ⇒ Object



10
11
12
13
14
15
16
# File 'lib/validators/article_validator.rb', line 10

def self.validate(articles)
  return if articles.empty?
  articles.each do |article|
    next if article.is_a?(Article)
    fail ArgumentError, format(ARTICLE_CLASS_ERROR, article.class)
  end
end