Class: EasyTalk::Model::SchemaValidator
- Inherits:
-
ActiveModel::Validator
- Object
- ActiveModel::Validator
- EasyTalk::Model::SchemaValidator
- Defined in:
- lib/easy_talk/model.rb
Instance Method Summary collapse
Instance Method Details
#schema_validation(record) ⇒ Object
54 55 56 57 58 |
# File 'lib/easy_talk/model.rb', line 54 def schema_validation(record) schema = JSONSchemer.schema(record.class.json_schema) errors = schema.validate(record.properties) SchemaErrorsMapper.new(errors) end |
#validate(record) ⇒ Object
47 48 49 50 51 52 |
# File 'lib/easy_talk/model.rb', line 47 def validate(record) result = schema_validation(record) result.errors.each do |key, error_msg| record.errors.add key.to_sym, error_msg end end |