You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by "Hasan Turksoy (JIRA)" <ji...@apache.org> on 2007/02/19 11:07:05 UTC

[jira] Created: (VALIDATOR-225) locale aware validator scripts required

locale aware validator scripts required
---------------------------------------

                 Key: VALIDATOR-225
                 URL: https://issues.apache.org/jira/browse/VALIDATOR-225
             Project: Commons Validator
          Issue Type: Bug
          Components: JavaScript
    Affects Versions: 1.3.1 Release
         Environment: shale1.0.4, JSF1.1
            Reporter: Hasan Turksoy


when the locale is EN: thousand seperator="," ,  decimal seperator='.' (like: 123,45.67)
when the locale is TR(my case): thousand seperator="." ,  decimal seperator=',' (like: 123.45,67)
 
as far as i can see, validator javascripts written for EN locale in mind.. so, validator scripts are not working properly for my situation...
 
for example, for the above value, validateFloat will split my number after 123.. i didn't control all but some other validators may fail in such a situation too..

A solution that we can apply to commons-validator might be like this;
ValidatorScript component reaches necessary localized symbols and puts them into a localeSpecificSymbols[] array... resulting javascipt code will be like this:

------------------------------------------------------------------
var GROUPING_SEPARATOR_INDEX = 0;
var DECIMAL_SEPARATOR_INDEX = 1;

var localeSpecificSymbols = {'.', ',', .....};
------------------------------------------------------------------

by this way, any validator which needs one of these symbols can reach this symbols array and use it as necessary....

example validateFloat implementation code will then be like:
var tempArray = value.split(localeSpecificSymbols[DECIMAL_SEPARATOR_INDEX]);
instead of
var tempArray = value.split('.');

i have injected this solution into my local commons-validator and shale jars and it's succeeded :)...

PS : sorry for the incorrect code parts.. i can not reach my original code for now.. written them only for visualize the problem and solution.. however, i can send the correct code later, if required..

regards..

hasan..


-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org