Class: Datacite::Validators::AttributesValidator
- Inherits:
-
Object
- Object
- Datacite::Validators::AttributesValidator
- Defined in:
- lib/datacite/validators/attributes_validator.rb
Overview
Validate a hash of attributes against the DataCite schema
Instance Method Summary collapse
- #errors ⇒ Object
-
#initialize(attributes:) ⇒ AttributesValidator
constructor
A new instance of AttributesValidator.
-
#valid? ⇒ Boolean
True if valid, false if not.
Constructor Details
#initialize(attributes:) ⇒ AttributesValidator
Returns a new instance of AttributesValidator.
11 12 13 |
# File 'lib/datacite/validators/attributes_validator.rb', line 11 def initialize(attributes:) @attributes = attributes end |
Instance Method Details
#errors ⇒ Object
20 21 22 |
# File 'lib/datacite/validators/attributes_validator.rb', line 20 def errors results.map { |result| result.fetch('error') } end |
#valid? ⇒ Boolean
Returns true if valid, false if not.
16 17 18 |
# File 'lib/datacite/validators/attributes_validator.rb', line 16 def valid? results.none? # If there are no results (an Enumerator), there were no errors, thus valid end |