File tree Expand file tree Collapse file tree 1 file changed +7
-3
lines changed
Expand file tree Collapse file tree 1 file changed +7
-3
lines changed Original file line number Diff line number Diff line change @@ -15,6 +15,7 @@ var BlueprintController = {
1515 , populate : require ( './api/blueprints/populate' )
1616} ;
1717var JsonApiService = require ( './api/services/JsonApiService' ) ;
18+ var jsonApiValidator = require ( './context-aware-jsonapi-validator/validator' ) ;
1819var responseOk = require ( './api/responses/ok' ) ;
1920var responseCreated = require ( './api/responses/created' ) ;
2021var responseNotFound = require ( './api/responses/notFound' ) ;
@@ -137,9 +138,12 @@ module.exports = function(sails) {
137138 if ( strncmp ( controller [ name ] . _middlewareType , "BLUEPRINT: " , "BLUEPRINT: " . length ) === true ) {
138139 controller [ name ] = function ( req , res ) {
139140
140- if ( req . method !== 'GET' && req . method !== 'DELETE' &&
141- JsonApiService . validate ( req . body ) === false ) {
142- return res . invalidJsonApi ( ) ;
141+ if ( req . method === 'POST' || req . method === 'PATCH' ) {
142+
143+ var context = ( req . method === 'POST' ) ? jsonApiValidator . CONTEXT_CREATE : jsonApiValidator . CONTEXT_UPDATE ;
144+
145+ if ( JsonApiService . validate ( req . body , context ) === false )
146+ return res . invalidJsonApi ( ) ;
143147 }
144148
145149 req . body = JsonApiService . deserialize ( req . body ) ;
You can’t perform that action at this time.
0 commit comments