Details
-
Type:
Bug
-
Status:
Resolved
-
Priority:
Blocker
-
Resolution: Fixed
-
Affects Version/s: 1.10.1
-
Fix Version/s: 1.10.3
-
Component/s: Zend_Locale
-
Labels:None
Description
Is Zend_Validate_Int seriously broken with non-english locales or is it just me? Because we're facing two different problems.
- In order to validate an integer using the french format (with spaces as thousands separator, ie: 8 000), the framework expects us to input digits separated with non-breakable spaces (ie: 8(\xA0)000). Is this a sad joke? Because I don't even know how to input a non-breakable space using my keyboard. Regular spaces are not allowed. Sure you can still avoid thousands separators, but in this case, a second problem appears..
(this issue is discussed here, I can understand it's not really an issue, but still: http://framework.zend.com/issues/browse/ZF-7175)
- So you can't validate a french space-separated number, let's use a number with no separators at all. Unfortunately, that does not seem to be a solution either, since you didn't specified the 'u' modifier in the preg_match() that validates the number format in Zend_Locale_Format (line 503). And it seems that the non-breakable space is a special UTF-8 character that you can't use in UTF-8 regex without the 'u' modifier. At least, adding the 'u' modifier makes it work like a charm.
So basically, you can't use integers in french.
Issue not reproducable.
Running the following testcode I get "true":
$date = new Zend_Validate_Int('fr'); var_dump($date->isValid('1 234'));Regarding space as separator:
This will not be implemented as it's a false behaviour.
As you can see in the above example code using a non-breaking space as separator is accepted and returns true. Note that this works even without using /u as non-breaking space is no special utf8 character.
When you want to allow your users to enter non-integers (with whitespaces) and have them accepted as integer then you need to add a filter which converts nb-space to space.
As example, your proposed change would allow the user to enter "123 456 789"... in this case you would never know if he entered 3 independend numbers or if he entered 3 seperated numers.
$date = new Zend_Validate_Int('fr'); var_dump($date->isValid('1 234'));