As per below code I am validate JSON data but it giving me the error
var filter = [{api_access: 'json', social_parameters: 'json', social_data: 'json'}];
req.validator(filter, false, function(err, params){
// err === {message: 'parsedError...', invalidParameters: ['invalid', 'parameter', 'list']}
if(err) return res.badRequest({'error':err.message});
});
The response is
{
"error": " api_access: [object Object], has to be json type. social_parameters: [object Object], has to be json type. social_data: [object Object], has to be json type."
}
The Model in sails.js with waterLine ORM
module.exports = {
attributes: {
api_access:{
type: 'json',
required: true
},
social_parameters:{
type: 'json',
required: true
},
social_data: {
type: 'json',
required: true
},
}
}
The Postman Collection sending with Post Data
{
"api_access":{
"key":"XXXXXXXXXX",
"pwd":"XXXXXXXXXXX"
},
"social_parameters":{
"access_token":"8eZWROguE3Bt3OmA2SRugfYD"
},
"social_data":{
"message":"XXXXX",
"name":"xxxxxxxx",
"link":"xxxxxxxxx",
"picture": "XXXXX",
"description" : "XXXXX",
"page_id":"XXXXXXXXXXXXX"
}
}