Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

How to provide custom model validation message in Sails.js?

How to provide custom model validation message in Sails.js?

Problem

How to provide Custom Model Validation message in Sails.js?

The validation messages returned by Sails.js is not user friendly so I wanted to provide a custom validation message for rules like required, minLength etc... but don't really know how. It's not in the docs and I also checked the docs of Anchor.js w/c is the validator used by Sails but its also not there.

UPDATE:

Haven't got a response last week so I implemented my own solution, wanted to share it since it might be useful for others - How I use custom validation messages in Sails.js

Another alternative and better way is to use the solution of @Rifat found in the comments below :)

Another very good alternative (credits to: sfb_ ) - https://gist.github.com/basco-johnkevin/8436644

Problem courtesy of: John Kevin M. Basco

Solution

Since Sails.js doesn't yet support using custom model validation messages, we can use these solutions:

1) @johnkevinmbasco's solution

2) @sfb_'s solution

3) @rifats solution

Solution courtesy of: John Kevin M. Basco

Discussion

View additional discussion.



This post first appeared on Node.js Recipes, please read the originial post: here

Share the post

How to provide custom model validation message in Sails.js?

×

Subscribe to Node.js Recipes

Get updates delivered right to your inbox!

Thank you for your subscription

×