File tree Expand file tree Collapse file tree 3 files changed +9
-1
lines changed Expand file tree Collapse file tree 3 files changed +9
-1
lines changed Original file line number Diff line number Diff line change @@ -15,7 +15,7 @@ module.exports = {
1515 title : "Last name" ,
1616 } ,
1717 age : {
18- type : "integer" ,
18+ type : [ "integer" , "null" ] ,
1919 title : "Age" ,
2020 } ,
2121 bio : {
@@ -43,6 +43,7 @@ module.exports = {
4343 "ui:widget" : "updown" ,
4444 "ui:title" : "Age of person" ,
4545 "ui:description" : "(earthian year)" ,
46+ "ui:emptyValue" : null ,
4647 } ,
4748 bio : {
4849 "ui:widget" : "textarea" ,
Original file line number Diff line number Diff line change @@ -272,6 +272,9 @@ export function asNumber(value) {
272272 if ( value === "" ) {
273273 return undefined ;
274274 }
275+ if ( value === null ) {
276+ return null ;
277+ }
275278 if ( / \. $ / . test ( value ) ) {
276279 // "3." can't really be considered a number even if it parses in js. The
277280 // user is most likely entering a float.
Original file line number Diff line number Diff line change @@ -342,6 +342,10 @@ describe("utils", () => {
342342 it ( "should return undefined if the input is empty" , ( ) => {
343343 expect ( asNumber ( "" ) ) . eql ( undefined ) ;
344344 } ) ;
345+
346+ it ( "should return null if the input is null" , ( ) => {
347+ expect ( asNumber ( null ) ) . eql ( null ) ;
348+ } ) ;
345349 } ) ;
346350
347351 describe ( "orderProperties()" , ( ) => {
You can’t perform that action at this time.
0 commit comments