i'm using sails , have created model, , of attributes required, if post json of attributes missing still create record in db. i'm using sails-postgresql
. i've tried doing manually with:
modelname.create(req.body).done(function(){})
you need add special fields models attributes - "required: true" or "minlength: 5"
module.exports = { attributes: { name: { type: 'string', maxlength: 20, minlength: 5 }, email: { type: 'email', required: true } } }
you can read validation in sails models here - http://sailsjs.org/#!documentation/models
Comments
Post a Comment