File tree Expand file tree Collapse file tree 2 files changed +15
-1
lines changed
Expand file tree Collapse file tree 2 files changed +15
-1
lines changed Original file line number Diff line number Diff line change @@ -315,7 +315,7 @@ SchemaType.prototype = {
315315 name : 'oneOf' ,
316316 test ( value ) {
317317 let valids = this . schema . _whitelist
318- if ( valids . length && ! valids . has ( value ) )
318+ if ( valids . length && ! ( valids . has ( value ) || isAbsent ( value ) ) )
319319 return this . createError ( { params : { values : valids . values ( ) . join ( ', ' ) } } )
320320 return true
321321 }
Original file line number Diff line number Diff line change @@ -70,6 +70,20 @@ describe( 'Mixed Types ', function(){
7070 ] )
7171 } )
7272
73+ it ( 'should ignore absent values' , function ( ) {
74+ return Promise . all ( [
75+ mixed ( )
76+ . oneOf ( [ 'hello' ] )
77+ . isValid ( undefined )
78+ . should . eventually . equal ( true ) ,
79+ string ( )
80+ . nullable ( )
81+ . oneOf ( [ 'hello' ] )
82+ . isValid ( null )
83+ . should . eventually . equal ( true )
84+ ] )
85+ } )
86+
7387 it ( 'should exclude values' , function ( ) {
7488 var inst = mixed ( ) . notOneOf ( [ 'hello' , 5 ] )
7589
You can’t perform that action at this time.
0 commit comments