File tree Expand file tree Collapse file tree 2 files changed +10
-1
lines changed
Expand file tree Collapse file tree 2 files changed +10
-1
lines changed Original file line number Diff line number Diff line change @@ -45,7 +45,8 @@ module.exports = Any.extend({
4545 }
4646
4747 if ( typeof value === 'string' ) {
48- const normalized = schema . _flags . sensitive ? value : value . toLowerCase ( ) ;
48+ const trimmedValue = value . trim ( ) ;
49+ const normalized = schema . _flags . sensitive ? trimmedValue : trimmedValue . toLowerCase ( ) ;
4950 value = normalized === 'true' ? true : ( normalized === 'false' ? false : value ) ;
5051 }
5152
Original file line number Diff line number Diff line change @@ -31,6 +31,14 @@ describe('boolean', () => {
3131 ] ) ;
3232 } ) ;
3333
34+ it ( 'converts boolean string with trailing spaces to a boolean' , ( ) => {
35+
36+ Helper . validate ( Joi . boolean ( ) , [
37+ [ 'true ' , true , true ] ,
38+ [ 'false ' , true , false ]
39+ ] ) ;
40+ } ) ;
41+
3442 it ( 'does not convert boolean string to a boolean in strict mode' , ( ) => {
3543
3644 Helper . validate ( Joi . boolean ( ) . strict ( ) , [
You can’t perform that action at this time.
0 commit comments