From 39b49d47f971ca382525ecadc7729654d4073b23 Mon Sep 17 00:00:00 2001 From: Alexander Ljungberg Date: Sun, 10 Mar 2013 13:30:35 +0000 Subject: [PATCH] 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. --- Foundation/CPNumberFormatter.j | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Foundation/CPNumberFormatter.j b/Foundation/CPNumberFormatter.j index 105bfbd5f..2299ea10e 100644 --- a/Foundation/CPNumberFormatter.j +++ b/Foundation/CPNumberFormatter.j @@ -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 = @"";