File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -294,13 +294,12 @@ function plainString(
294294 return quotedString ( value , ctx )
295295 }
296296 if (
297- ! value ||
298297 / ^ [ \n \t , [ \] { } # & * ! | > ' " % @ ` ] | ^ [ ? - ] $ | ^ [ ? - ] [ \t ] | [ \n : ] [ \t ] | [ \t ] \n | [ \n \t ] # | [ \n \t : ] $ / . test (
299298 value
300299 )
301300 ) {
302301 // not allowed:
303- // - empty string, '-' or '?'
302+ // - '-' or '?'
304303 // - start with an indicator character (except [?:-]) or /[?-] /
305304 // - '\n ', ': ' or ' \n' anywhere
306305 // - '#' not preceded by a non-space char
Original file line number Diff line number Diff line change @@ -264,6 +264,16 @@ aliases:
264264 } )
265265} )
266266
267+ describe ( 'failsafe schema' , ( ) => {
268+ test ( 'empty scalars (#616)' , ( ) => {
269+ const doc = parseDocument ( 'empty:\n' , { schema : 'failsafe' } )
270+ expect ( doc . errors ) . toMatchObject ( [ ] )
271+ expect ( doc . get ( 'empty' , true ) ) . toMatchObject ( { value : '' } )
272+ expect ( doc . toJS ( ) ) . toMatchObject ( { empty : '' } )
273+ expect ( doc . toString ( ) ) . toEqual ( 'empty:\n' )
274+ } )
275+ } )
276+
267277describe ( 'json schema' , ( ) => {
268278 test ( '!!bool' , ( ) => {
269279 const src = `"canonical": true
You can’t perform that action at this time.
0 commit comments