jaydata
jaydata copied to clipboard
Don't initialize empty strings with null in validation
This PR fixes issue #276
A brief summary: During validation of required properties, jaydata does not recognize the empty string "" as a value and will call .getDefault() to create an initial value for that property. This will overwrite the empty string with null, which is not correct - especially for properties whose schema have a nullable: false annotation.
A special JS "feature" conceals this behaviour: !entity.data[memDef.name] will evaluate to true for the empty string - because !"" evaluates to true. However, I think the original author of that line only intended to check for undefined and null. So I added one more check to see if the property is the empty string, and only if this is not the case the property is overriden with the default value.