← Back to team overview

dhis2-devs team mailing list archive

Re: [Branch ~dhis2-devs-core/dhis2/trunk] Rev 4611: added proper validation for real/natural numbers (including support for e-notation)

 

> Number. This is any real number, with an option single sign (-), a
> single decimal point and no thousand separators. Scientific notation
> is not allowed (but could be if there is a real need for it).

We don't really support real numbers.. we support integers, and
decimal approximations of rational numbers.. I think the name decimal
would be better here.

> Integer: Any whole number, including zero.
> Positive integers: Any whole number greater than zero.
> Negative integers: Any whole number less than zero.

These are good.

> As to whether users know what integers are, I am not sure. The current
> syntax we have is a bit technical, but adding more number types is
> likely to confuse things further It is detailed in the user manual,
> Data element chapter. I am not sure they necessarily know what a
> natural number is either but I am not opposed to the change of name if
> it is more clear.. Regardless, there are no negative natural numbers.
> :)

Yes, I think maybe integer is the way to go, since whole numbers is
not clearly defined. But I'm not a native speaker, so I'm not really
sure whats best.

> As for the support for scientific notation, I am not necessarily
> opposed to it, but think we need to stick to the more strict regex
> validation.

I think maybe supporting e-notation but restricting it might be more
confusing.. ? not sure here... maybe just plain decimals is OK.

> Have a look in
> dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/commons.js

Yes, looking there now.

--
Morten

> for details of the different regex checks we developed to support the
> current four number types.
>
> Hope this helps.
> Jason
>
>
>
> On Mon, Sep 19, 2011 at 8:48 AM, Hieu Dang Duy
> <hieu.hispvietnam@xxxxxxxxx> wrote:
>>
>>
>> On Mon, Sep 19, 2011 at 1:42 PM, Morten Olav Hansen <mortenoh@xxxxxxxxx>
>> wrote:
>>>
>>> Hi
>>>
>>> > I agree with these validation on field but why don't you apply the "Math
>>> > methods" - which are in commons - into them. The "Math methods" are
>>> > working
>>> > on regex that I think it is very very robust in validating.
>>>
>>> Ok, sounds good. What are they named? I never found any validations
>>> for positive/negative numbers..
>>>
>>
>> Yes, they are isRealNumber() which is including in positive/negative
>> numbers, isNegativeInt(), and isPositiveInt().
>>
>>>
>>> > Btw, the name of method "positive/negative_natural_number" is quite
>>> > sensitive to me.
>>>
>>> The naming here is a bit off. I need suggestions here, even whole
>>> numbers is not defined always mean the set of all integers.
>>>
>>> --
>>> Morten
>>
>> About this you could also ask Jason for more suggestion.
>>
>> --
>> "Expert By Chance"
>>
>>
>


Follow ups

References