Make it easy to apply options to all paths in a schema
See original GitHub issueHello,
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:
- Created 11 years ago
- Reactions:1
- Comments:21
Top 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 >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
For example i have field
name
. For user it is not required to set it, so it can beundefined
. 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 thatvalue !== ''
.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 withSchema#eachPath()