[0.4] Keystone should use the Mongoose validate
See original GitHub issueI think it would be cool if keystone can make use of a field’s schema validate function that may be configured in the field. The issue with letting mongoose process it is that input values are all cleared upon a fail validation as well as auto focus of an invalid field does not work. For example:
description: {
type: Types.Html,
validate: {
validator: function(v) {
return (v && v.length > 0)
},
message: 'Please provide a description!'
}
},
keystone should check if a validate/validator is defined and make use of it so that it may address the issues above.
Issue Analytics
- State:
- Created 8 years ago
- Comments:7 (5 by maintainers)
Top Results From Across the Web
Read Practical Keystone.js | Leanpub
We will cover how to install MongoDB and Node.js that are needed create the IncTicket application using Keystone.js and run it. This chapter...
Read more >Mongoose v6.8.2: Validation
Validation is defined in the SchemaType. Validation is middleware. Mongoose registers validation as a pre('save') hook on every schema by default. You can...
Read more >keystonejs/keystone - Gitter
Hi guys! Quick question: I have two models connected via "many" relationship. Is it possible to add new item to the child model...
Read more >Keystone-impatient NPM | npm.io
KeystoneJS is a powerful Node.js content management system and web app framework built on express and mongoose. Keystone makes it easy to create ......
Read more >keystone-utils - npm
A useful library of utilities used by KeystoneJS, and you!. Latest version: 0.4.0, last published: 7 years ago. Start using keystone-utils ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Is there ANY way to show a custom error message with the Mongoose validator?
I see no value in having KS swallow the validator. I prefer seeing an explicit mongoose validator, since I know what it does. The less API surface for Keystone the better, since it’s yet another thing less to a) maintain, document etc b) learn when starting out with KS. If it’s not a facade or adapter it’s not valuable IMO.
I.e. close this muthafucker! 😉 Close all the issues! MUHAHAHAAA Sorry, got a bit carried away.