|
I'm using Zend_Validate_Float to validate a form field, but I set the
PHP locale to pt_BR, when I input some value with no decimals, it works fine, but, if I put, like 20,52 it returns false. After making some tests I've found out that it's because Zend_Validate_Float uses strval, which considers the locale and replaces the decimal point. I'm not sure wheter that's a bug or not, if it is, where can I report it? Thanks -- Felipe Weckx <[hidden email]> MT4 Tecnologia |
|
Hi, This is not a bug, but rather a feature request. I'd suggest a new filter for this: Zend_Validate_Currency perhaps. Thomas W. will know more about this. Best, Andries Seutens http://andries.systray.be Felipe Weckx schreef: > I'm using Zend_Validate_Float to validate a form field, but I set the > PHP locale to pt_BR, when I input some value with no decimals, it > works fine, but, if I put, like 20,52 it returns false. After making > some tests I've found out that it's because Zend_Validate_Float uses > strval, which considers the locale and replaces the decimal point. I'm > not sure wheter that's a bug or not, if it is, where can I report it? > > Thanks > Gecontroleerd op virussen door de JOJO Secure Gateway. |
|
No... this has nothing to do with currency.
The problem is that when a locale other than 'en' is used, and you do a string conversion of the float value, you will always get the locale's string representation returned for all php functions. Within Zend_Locale I fixed those problems which allows to work with all locales independently of the locale set within php, but as Zend_Validate (which is core not i18n) does not rely on Zend_Locale it's not working with it and has to be fixed seperate or make it dependent with Zend_Locale_Format. There is already an issue for that http://framework.zend.com/issues/browse/ZF-1882 The problem is identical for Int and Float. Greetings Thomas Weidner, I18N Team Leader http://www.thomasweidner.com ----- Original Message ----- From: "Andries Seutens" <[hidden email]> To: "Felipe Weckx" <[hidden email]> Cc: <[hidden email]>; "Thomas Weidner" <[hidden email]> Sent: Thursday, January 31, 2008 1:41 PM Subject: Re: [fw-i18n] Zend_Validate_Float locale problem > > Hi, > > This is not a bug, but rather a feature request. I'd suggest a new > filter for this: > Zend_Validate_Currency perhaps. > > Thomas W. will know more about this. > > Best, > > Andries Seutens > http://andries.systray.be > > > > Felipe Weckx schreef: >> I'm using Zend_Validate_Float to validate a form field, but I set the >> PHP locale to pt_BR, when I input some value with no decimals, it >> works fine, but, if I put, like 20,52 it returns false. After making >> some tests I've found out that it's because Zend_Validate_Float uses >> strval, which considers the locale and replaces the decimal point. I'm >> not sure wheter that's a bug or not, if it is, where can I report it? >> >> Thanks >> > -------------------------------------------------------------------------------- > Gecontroleerd op virussen door de JOJO Secure Gateway. > |
|
Hi Thomas,
Thanks for the clarification :) Best, Andries Thomas Weidner schreef: > No... this has nothing to do with currency. > The problem is that when a locale other than 'en' is used, and you do a > string conversion of the float value, you will always get the locale's > string representation returned for all php functions. > > Within Zend_Locale I fixed those problems which allows to work with all > locales independently of the locale set within php, but as Zend_Validate > (which is core not i18n) does not rely on Zend_Locale it's not working > with it and has to be fixed seperate or make it dependent with > Zend_Locale_Format. > > There is already an issue for that > http://framework.zend.com/issues/browse/ZF-1882 > The problem is identical for Int and Float. > > Greetings > Thomas Weidner, I18N Team Leader > http://www.thomasweidner.com > > ----- Original Message ----- From: "Andries Seutens" > <[hidden email]> > To: "Felipe Weckx" <[hidden email]> > Cc: <[hidden email]>; "Thomas Weidner" <[hidden email]> > Sent: Thursday, January 31, 2008 1:41 PM > Subject: Re: [fw-i18n] Zend_Validate_Float locale problem > > >> >> Hi, >> >> This is not a bug, but rather a feature request. I'd suggest a new >> filter for this: >> Zend_Validate_Currency perhaps. >> >> Thomas W. will know more about this. >> >> Best, >> >> Andries Seutens >> http://andries.systray.be >> >> >> >> Felipe Weckx schreef: >>> I'm using Zend_Validate_Float to validate a form field, but I set the >>> PHP locale to pt_BR, when I input some value with no decimals, it >>> works fine, but, if I put, like 20,52 it returns false. After making >>> some tests I've found out that it's because Zend_Validate_Float uses >>> strval, which considers the locale and replaces the decimal point. I'm >>> not sure wheter that's a bug or not, if it is, where can I report it? >>> >>> Thanks >>> >> > > > -------------------------------------------------------------------------------- > > > >> Gecontroleerd op virussen door de JOJO Secure Gateway. >> > > > |
|
In reply to this post by Thomas Weidner
You could use
Zend_Locale_Format::isFloat or Zend_Locale_Format::isInteger if this fit's your needs for validation. They are both locale-aware and can also check inputs from different locale-strings. Also it would be good to know if they could be improved, because until now there were no responses to this one. Could mean that it works without problems, or that no body know them... I expect second :-) Greetings Thomas Weidner, I18N Team Leader http://www.thomasweidner.com ----- Original Message ----- From: "Felipe Weckx" <[hidden email]> To: "Thomas Weidner" <[hidden email]> Sent: Thursday, January 31, 2008 6:43 PM Subject: Re: [fw-i18n] Zend_Validate_Float locale problem > Ok, I'll just use my own validation for now. Sorry for posting in the > wrong list. > > Thanks for the explanation, hope this gets fixed soon. > > > Thomas Weidner escreveu: >> No... this has nothing to do with currency. >> The problem is that when a locale other than 'en' is used, and you do a >> string conversion of the float value, you will always get the locale's >> string representation returned for all php functions. >> >> Within Zend_Locale I fixed those problems which allows to work with all >> locales independently of the locale set within php, but as Zend_Validate >> (which is core not i18n) does not rely on Zend_Locale it's not working >> with it and has to be fixed seperate or make it dependent with >> Zend_Locale_Format. >> >> There is already an issue for that >> http://framework.zend.com/issues/browse/ZF-1882 >> The problem is identical for Int and Float. >> >> Greetings >> Thomas Weidner, I18N Team Leader >> http://www.thomasweidner.com >> >> ----- Original Message ----- From: "Andries Seutens" >> <[hidden email]> >> To: "Felipe Weckx" <[hidden email]> >> Cc: <[hidden email]>; "Thomas Weidner" <[hidden email]> >> Sent: Thursday, January 31, 2008 1:41 PM >> Subject: Re: [fw-i18n] Zend_Validate_Float locale problem >> >> >>> >>> Hi, >>> >>> This is not a bug, but rather a feature request. I'd suggest a new >>> filter for this: >>> Zend_Validate_Currency perhaps. >>> >>> Thomas W. will know more about this. >>> >>> Best, >>> >>> Andries Seutens >>> http://andries.systray.be >>> >>> >>> >>> Felipe Weckx schreef: >>>> I'm using Zend_Validate_Float to validate a form field, but I set the >>>> PHP locale to pt_BR, when I input some value with no decimals, it >>>> works fine, but, if I put, like 20,52 it returns false. After making >>>> some tests I've found out that it's because Zend_Validate_Float uses >>>> strval, which considers the locale and replaces the decimal point. I'm >>>> not sure wheter that's a bug or not, if it is, where can I report it? >>>> >>>> Thanks >>>> >>> >> >> >> -------------------------------------------------------------------------------- >> >> >> >>> Gecontroleerd op virussen door de JOJO Secure Gateway. >>> >> >> >> > > -- > Felipe Weckx <[hidden email]> > MT4 Tecnologia > (11) 3064-3226 |
|
What if I want to filter a user supplied value into float that php
understands... ? Regards, Eric On Jan 31, 2008, at 1:30 PM, Thomas Weidner wrote: > You could use > Zend_Locale_Format::isFloat > or > Zend_Locale_Format::isInteger > if this fit's your needs for validation. > They are both locale-aware and can also check inputs from different > locale-strings. > > Also it would be good to know if they could be improved, because > until now > there were no responses to this one. > Could mean that it works without problems, or that no body know > them... I > expect second :-) > > Greetings > Thomas Weidner, I18N Team Leader > http://www.thomasweidner.com > > ----- Original Message ----- From: "Felipe Weckx" <[hidden email]> > To: "Thomas Weidner" <[hidden email]> > Sent: Thursday, January 31, 2008 6:43 PM > Subject: Re: [fw-i18n] Zend_Validate_Float locale problem > > >> Ok, I'll just use my own validation for now. Sorry for posting in >> the wrong list. >> >> Thanks for the explanation, hope this gets fixed soon. >> >> >> Thomas Weidner escreveu: >>> No... this has nothing to do with currency. >>> The problem is that when a locale other than 'en' is used, and you >>> do a string conversion of the float value, you will always get the >>> locale's string representation returned for all php functions. >>> >>> Within Zend_Locale I fixed those problems which allows to work >>> with all locales independently of the locale set within php, but >>> as Zend_Validate (which is core not i18n) does not rely on >>> Zend_Locale it's not working with it and has to be fixed seperate >>> or make it dependent with Zend_Locale_Format. >>> >>> There is already an issue for that http://framework.zend.com/issues/browse/ZF-1882 >>> The problem is identical for Int and Float. >>> >>> Greetings >>> Thomas Weidner, I18N Team Leader >>> http://www.thomasweidner.com >>> >>> ----- Original Message ----- From: "Andries Seutens" <[hidden email] >>> > >>> To: "Felipe Weckx" <[hidden email]> >>> Cc: <[hidden email]>; "Thomas Weidner" <[hidden email] >>> > >>> Sent: Thursday, January 31, 2008 1:41 PM >>> Subject: Re: [fw-i18n] Zend_Validate_Float locale problem >>> >>> >>>> >>>> Hi, >>>> >>>> This is not a bug, but rather a feature request. I'd suggest a new >>>> filter for this: >>>> Zend_Validate_Currency perhaps. >>>> >>>> Thomas W. will know more about this. >>>> >>>> Best, >>>> >>>> Andries Seutens >>>> http://andries.systray.be >>>> >>>> >>>> >>>> Felipe Weckx schreef: >>>>> I'm using Zend_Validate_Float to validate a form field, but I >>>>> set the >>>>> PHP locale to pt_BR, when I input some value with no decimals, it >>>>> works fine, but, if I put, like 20,52 it returns false. After >>>>> making >>>>> some tests I've found out that it's because Zend_Validate_Float >>>>> uses >>>>> strval, which considers the locale and replaces the decimal >>>>> point. I'm >>>>> not sure wheter that's a bug or not, if it is, where can I >>>>> report it? >>>>> >>>>> Thanks >>>>> >>>> >>> >>> >>> -------------------------------------------------------------------------------- >>> >>> >>> >>>> Gecontroleerd op virussen door de JOJO Secure Gateway. >>>> >>> >>> >>> >> >> -- >> Felipe Weckx <[hidden email]> >> MT4 Tecnologia >> (11) 3064-3226 > |
|
Same problem....
Zend_Filter is not locale-aware, has no workaround and does not use Zend_Locale. You would have to do the same as Felipe und extend/write your own filter/validator with Zend_Locale or do it yourself. I don't know if such an issue exists for Zend_Filter... if not feel free to open one. Greetings Thomas Weidner, I18N Team Leader http://www.thomasweidner.com ----- Original Message ----- From: "Eric Coleman" <[hidden email]> To: <[hidden email]> Sent: Thursday, January 31, 2008 7:37 PM Subject: Re: [fw-i18n] Zend_Validate_Float locale problem > What if I want to filter a user supplied value into float that php > understands... ? > > Regards, > Eric > > > On Jan 31, 2008, at 1:30 PM, Thomas Weidner wrote: > >> You could use >> Zend_Locale_Format::isFloat >> or >> Zend_Locale_Format::isInteger >> if this fit's your needs for validation. >> They are both locale-aware and can also check inputs from different >> locale-strings. >> >> Also it would be good to know if they could be improved, because until >> now >> there were no responses to this one. >> Could mean that it works without problems, or that no body know them... >> I >> expect second :-) >> >> Greetings >> Thomas Weidner, I18N Team Leader >> http://www.thomasweidner.com >> >> ----- Original Message ----- From: "Felipe Weckx" <[hidden email]> >> To: "Thomas Weidner" <[hidden email]> >> Sent: Thursday, January 31, 2008 6:43 PM >> Subject: Re: [fw-i18n] Zend_Validate_Float locale problem >> >> >>> Ok, I'll just use my own validation for now. Sorry for posting in the >>> wrong list. >>> >>> Thanks for the explanation, hope this gets fixed soon. >>> >>> >>> Thomas Weidner escreveu: >>>> No... this has nothing to do with currency. >>>> The problem is that when a locale other than 'en' is used, and you do >>>> a string conversion of the float value, you will always get the >>>> locale's string representation returned for all php functions. >>>> >>>> Within Zend_Locale I fixed those problems which allows to work with >>>> all locales independently of the locale set within php, but as >>>> Zend_Validate (which is core not i18n) does not rely on Zend_Locale >>>> it's not working with it and has to be fixed seperate or make it >>>> dependent with Zend_Locale_Format. >>>> >>>> There is already an issue for that >>>> http://framework.zend.com/issues/browse/ZF-1882 >>>> The problem is identical for Int and Float. >>>> >>>> Greetings >>>> Thomas Weidner, I18N Team Leader >>>> http://www.thomasweidner.com >>>> >>>> ----- Original Message ----- From: "Andries Seutens" >>>> <[hidden email] >>>> > >>>> To: "Felipe Weckx" <[hidden email]> >>>> Cc: <[hidden email]>; "Thomas Weidner" <[hidden email] >>>> > >>>> Sent: Thursday, January 31, 2008 1:41 PM >>>> Subject: Re: [fw-i18n] Zend_Validate_Float locale problem >>>> >>>> >>>>> >>>>> Hi, >>>>> >>>>> This is not a bug, but rather a feature request. I'd suggest a new >>>>> filter for this: >>>>> Zend_Validate_Currency perhaps. >>>>> >>>>> Thomas W. will know more about this. >>>>> >>>>> Best, >>>>> >>>>> Andries Seutens >>>>> http://andries.systray.be >>>>> >>>>> >>>>> >>>>> Felipe Weckx schreef: >>>>>> I'm using Zend_Validate_Float to validate a form field, but I set >>>>>> the >>>>>> PHP locale to pt_BR, when I input some value with no decimals, it >>>>>> works fine, but, if I put, like 20,52 it returns false. After making >>>>>> some tests I've found out that it's because Zend_Validate_Float uses >>>>>> strval, which considers the locale and replaces the decimal point. >>>>>> I'm >>>>>> not sure wheter that's a bug or not, if it is, where can I report >>>>>> it? >>>>>> >>>>>> Thanks >>>>>> >>>>> >>>> >>>> >>>> -------------------------------------------------------------------------------- >>>> >>>> >>>> >>>>> Gecontroleerd op virussen door de JOJO Secure Gateway. >>>>> >>>> >>>> >>>> >>> >>> -- >>> Felipe Weckx <[hidden email]> >>> MT4 Tecnologia >>> (11) 3064-3226 >> |
| Powered by Nabble | Edit this page |
