File tree Expand file tree Collapse file tree 2 files changed +54
-1
lines changed Expand file tree Collapse file tree 2 files changed +54
-1
lines changed Original file line number Diff line number Diff line change 470470 "valid" : false
471471 }
472472 ]
473+ },
474+ {
475+ "description" : " select keyword with boolean selector tag (issue #150)" ,
476+ "schema" : {
477+ "type" : " object" ,
478+ "properties" : {
479+ "tag" : {"type" : " boolean" }
480+ },
481+ "select" : {
482+ "$data" : " 0/tag"
483+ },
484+ "selectCases" : {
485+ "false" : {
486+ "not" : {"required" : [" foo" ]}
487+ },
488+ "true" : {
489+ "required" : [" foo" ]
490+ }
491+ },
492+ "selectDefault" : false
493+ },
494+ "tests" : [
495+ {
496+ "description" : " false tag: valid" ,
497+ "data" : {"tag" : false },
498+ "valid" : true
499+ },
500+ {
501+ "description" : " false tag: invalid" ,
502+ "data" : {"tag" : false , "foo" : 1 },
503+ "valid" : false
504+ },
505+ {
506+ "description" : " true tag: valid" ,
507+ "data" : {"tag" : true , "foo" : 1 },
508+ "valid" : true
509+ },
510+ {
511+ "description" : " true tag: invalid" ,
512+ "data" : {"tag" : true },
513+ "valid" : false
514+ },
515+ {
516+ "description" : " no tag - select not validated 1 (valid)" ,
517+ "data" : {"foo" : 1 },
518+ "valid" : true
519+ },
520+ {
521+ "description" : " no tag - select not validated 1 (valid)" ,
522+ "data" : {},
523+ "valid" : true
524+ }
525+ ]
473526 }
474527]
Original file line number Diff line number Diff line change @@ -33,7 +33,7 @@ export default function getDef(opts?: DefinitionOptions): KeywordDefinition[] {
3333 gen . if ( false ) // optimizer should remove it from generated code
3434 for ( const schemaProp in parentSchema . selectCases ) {
3535 cxt . setParams ( { schemaProp} )
36- gen . elseIf ( _ `${ value } == ${ schemaProp } ` ) // intentional ==, to match numbers and booleans
36+ gen . elseIf ( _ `"" + ${ value } == ${ schemaProp } ` ) // intentional ==, to match numbers and booleans
3737 const schCxt = cxt . subschema ( { keyword : "selectCases" , schemaProp} , schValid )
3838 cxt . mergeEvaluated ( schCxt , Name )
3939 gen . assign ( valid , schValid )
You can’t perform that action at this time.
0 commit comments