emberjs/data — Issue #125: isEmpty(val) attribute option
Author: NickFranceschina
Created: 2012-02-28 06:36:35+00:00
State: open

now that defaultValue is done... I'm realizing it isn't exactly what I wanted. I'm looking to provide a "default value" for attributes that come back from the server set to null

{status: null}

I think the defaultValue stuff is correct.... so I'm looking for something more like an option that looks like

{isEmpty: "default status"}

if the attribute exists, but is empty (null? empty string? empty object?) then it would return whatever is specified here.

user : Ds.attr('object', {isEmpty:{name:"anonymous"}})

a case I often have this issue crop up is for nested objects... where I want to say "if the nested object is null, then return the empty object {}"... then my code will always know it is getting an object back from that property, and I dont have to put lots of null checks everywhere.

profile : Ds.attr('object', {isEmpty:{}})