Fixed: CPNumberFormatter formatted @"" as any number.

Without this fix, `- CPNumberFormatter getObjectValue:forString:errorDescription:` would return `YES` for string @"", like if it was properly converted to an object value, but then actually leave object value unchanged.

With this fix object value is set to nil like in Cocoa.

Refs #1829.
This commit is contained in:
Alexander Ljungberg committed 2013-03-10 13:30:35 +00:00
1 parent c550cd7afb
commit 39b49d47f9
1 file changed
+4 -1
+4 -1
View File
@@ -183,9 +183,12 @@ var NumberRegex = new RegExp('(-)?(\\d*)(\\.(\\d*))?');
- (BOOL)getObjectValue:(id)anObjectRef forString:(CPString)aString errorDescription:(CPString)anErrorRef
{
// allows an empty string to pass without validation
// Interpret an empty string as nil, like in Cocoa.
if (aString === @"")
{
@deref(anObjectRef) = nil;
return YES;
}
var value = [self numberFromString:aString],
error = @"";