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.

Make it easy to apply options to all paths in a schema

See original GitHub issue

Hello,

why such test in mongoose 3.4.0 failed?

describe('mongoose schama validator', function() {
    it('should failed if field is empty', function() {
        var Schema = mongoose.Schema({
          foo: {
            type: String,
           match: /[a-z]+/
        }});

        Schema.path('foo').doValidate('', function(err) {
            assert.ok(err instanceof ValidatorError); //err there is null
        });
    });
});

But `/[a-z]+/.test(‘’) is false:

den$ node
> /[a-z]+/.test('')
false
> 

Issue Analytics

  • State:closed
  • Created 11 years ago
  • Reactions:1
  • Comments:21

github_iconTop GitHub Comments

2reactions
btdcommented, Nov 22, 2012

For example i have field name. For user it is not required to set it, so it can be undefined. But if user set it, i want to check that it is not empty string. Currently as a workaround i add validator that simply check that value !== ''.

0reactions
vkarpov15commented, Jan 7, 2019

I’m going to close this. We added the ability to configure the checkRequired function in 5.4.0: http://thecodebarbarian.com/whats-new-in-mongoose-54-global-schematype-configuration.html , https://mongoosejs.com/docs/api.html#schematype_SchemaType-checkRequired, and OP’s issue can be resolved with Schema#eachPath()

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to use the Schema Paths Tool
You can access the Schema Paths Tool from the Schema App homepage by selecting Resource > Tools > Schema Paths. It can also...
Read more >
How to use the Schema Paths Tool - YouTube
At Schema App, we want to make sure you're getting the most out of your structured data! One of the best ways to...
Read more >
How to get paths for relocatable schemas in Gio.Settings?
It can list the subpaths of a given path, but that's about it. It's up for the application, when creating multiple instances of...
Read more >
Documentation: 15: 5.9. Schemas - PostgreSQL
Keep the default search path, and grant privileges to create in the public schema. All users access the public schema implicitly. This simulates...
Read more >
Setting crawler configuration options - AWS Glue
Learn about how to configure what a crawler does when it encounters schema changes and partition changes in your data store.
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