Module: JsonTableSchema::Validate
- Included in:
- Schema
- Defined in:
- lib/jsontableschema/validate.rb
Instance Attribute Summary collapse
-
#messages ⇒ Object
readonly
Returns the value of attribute messages.
Instance Method Summary collapse
Instance Attribute Details
#messages ⇒ Object (readonly)
Returns the value of attribute messages.
4 5 6 |
# File 'lib/jsontableschema/validate.rb', line 4 def @messages end |
Instance Method Details
#load_validator! ⇒ Object
6 7 8 9 |
# File 'lib/jsontableschema/validate.rb', line 6 def load_validator! filepath = File.join(File.dirname(__FILE__), '..', '..', 'etc', 'schemas', 'json-table-schema.json') @validator ||= JSON.parse(File.read filepath) end |
#valid? ⇒ Boolean
11 12 13 14 |
# File 'lib/jsontableschema/validate.rb', line 11 def valid? validate @messages.count == 0 end |
#validate ⇒ Object
16 17 18 19 20 |
# File 'lib/jsontableschema/validate.rb', line 16 def validate @messages = JSON::Validator.fully_validate(@validator, self) check_primary_keys check_foreign_keys end |