question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[0.4] Keystone should use the Mongoose validate

See original GitHub issue

I 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:closed
  • Created 8 years ago
  • Comments:7 (5 by maintainers)

github_iconTop GitHub Comments

3reactions
suavelizardcommented, Oct 26, 2017

Is there ANY way to show a custom error message with the Mongoose validator?

3reactions
creynderscommented, Apr 30, 2016

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found