File tree 1 file changed +6
-3
lines changed
1 file changed +6
-3
lines changed Original file line number Diff line number Diff line change @@ -676,21 +676,24 @@ SchemaType.prototype.get = function(fn) {
676
676
SchemaType . prototype . validate = function ( obj , message , type ) {
677
677
if ( typeof obj === 'function' || obj && utils . getFunctionName ( obj . constructor ) === 'RegExp' ) {
678
678
let properties ;
679
- if ( message instanceof Object && ! type ) {
679
+ if ( typeof message === 'function' ) {
680
+ properties = { validator : obj , message : message } ;
681
+ properties . type = type || 'user defined' ;
682
+ } else if ( message instanceof Object && ! type ) {
680
683
properties = utils . clone ( message ) ;
681
684
if ( ! properties . message ) {
682
685
properties . message = properties . msg ;
683
686
}
684
687
properties . validator = obj ;
685
688
properties . type = properties . type || 'user defined' ;
686
689
} else {
687
- if ( ! message ) {
690
+ if ( message == null ) {
688
691
message = MongooseError . messages . general . default ;
689
692
}
690
693
if ( ! type ) {
691
694
type = 'user defined' ;
692
695
}
693
- properties = { message : message , type : type , validator : obj } ;
696
+ properties = { message : message , type : type , validator : obj } ;
694
697
}
695
698
696
699
if ( properties . isAsync ) {
You can’t perform that action at this time.
0 commit comments