0
votes

Here is my controller, I want to validate body parameter like name and mobile, email, etc. How to do that.

/**

module.exports = {

register:async(req,res,next)=>{ return res.send({ 'status': 'success','message':'registration successfully'},200); }

};

1

1 Answers

0
votes

Sails.js provides a feature called model attributes. By defining model attributes, Sails automatically takes care of most of the validation based on the attributes that you define.

Checkout https://sailsjs.com/documentation/concepts/models-and-orm/attributes to learn more about model attributes.

Additionally you can validate the request body data by using regular JavaScript validation methods and regular expressions(for mobile and email).