@@ -210,12 +210,16 @@ describe('schematype', function() {
210
210
211
211
it ( 'merges default validators (gh-14070)' , function ( ) {
212
212
class TestSchemaType extends mongoose . SchemaType { }
213
- TestSchemaType . set ( 'validate' , v => typeof v === 'string' ) ;
213
+ TestSchemaType . set ( 'validate' , checkIfString ) ;
214
214
215
215
const schemaType = new TestSchemaType ( 'test-path' , {
216
- validate : v => v . length === 2
216
+ validate : checkIfLength2
217
217
} ) ;
218
218
219
+ assert . equal ( schemaType . validators . length , 2 ) ;
220
+ assert . equal ( schemaType . validators [ 0 ] . validator , checkIfString ) ;
221
+ assert . equal ( schemaType . validators [ 1 ] . validator , checkIfLength2 ) ;
222
+
219
223
let err = schemaType . doValidateSync ( [ 1 , 2 ] ) ;
220
224
assert . ok ( err ) ;
221
225
assert . equal ( err . name , 'ValidatorError' ) ;
@@ -226,6 +230,13 @@ describe('schematype', function() {
226
230
227
231
err = schemaType . doValidateSync ( 'ab' ) ;
228
232
assert . ifError ( err ) ;
233
+
234
+ function checkIfString ( v ) {
235
+ return typeof v === 'string' ;
236
+ }
237
+ function checkIfLength2 ( v ) {
238
+ return v . length === 2 ;
239
+ }
229
240
} ) ;
230
241
231
242
describe ( 'set()' , function ( ) {
0 commit comments