Skip to content

Commit

Permalink
JsonApiService.validate can validate document given a context
Browse files Browse the repository at this point in the history
  • Loading branch information
dynamiccast committed Jul 11, 2016
1 parent a48cf5b commit f831dd7
Showing 1 changed file with 3 additions and 11 deletions.
14 changes: 3 additions & 11 deletions lib/api/services/JsonApiService.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
const _ = require("lodash");
const cleanObject = require('clean-object');
const JSONAPISerializer = require('json-api-serializer');
const jsonApiValidator = require('../../context-aware-jsonapi-validator/validator');
const Serializer = new JSONAPISerializer();
const JSONAPIValidator = require('jsonapi-validator').Validator;

var findRecords = require('../blueprints/find');
var findOneRecord = require('../blueprints/findone');
Expand Down Expand Up @@ -156,16 +156,8 @@ module.exports = {
return errors;
},

validate: function(data) {
validate: function(doc, strategy) {

var validator = new JSONAPIValidator();

try {
validator.validate(data);

return true;
} catch (e) {
return false;
}
return jsonApiValidator.isValid(doc, strategy);
}
}

0 comments on commit f831dd7

Please sign in to comment.