Regex validation format for the decimal input values

Hi,

We are entering the GPS coordinates values based on the readings display
from the GPS devices and the device display the values in the format as :
"XX.XXXXX" (approx 6 digits after decimal points) and the validation
applied as regex(., '^[0-9][0-9]*(.[0-9][0-9][0-9][0-9][0-9][0-9]?)?$')"
to confirm the same requirementsand it accepts the values like : 25.370121
or 55.100151 etc., but sometime the GPS device display the value as "25.222200"
, "23.076543" and the above validation does not allow to accept any value
with Zero as it is getting round off automatically replacing all the zeros
or (It may be correct for the decimal value). However the round off value
is not correct as per GPS location. Hence i am looking for a validation
format that should accept the value in above same format XX.XXXXXX
accepting values without getting it round off.

Thanks in advance for all the suggestions.

Thanks & regards,
Gurudayal Sahu

Hello,

Assuming that you want to retain the trailing '0's then I think the best
option would be to make the GPS entry fields String questions and save
these values as strings, then cast them to doubles when you need to to
validation or other number logic. The Decimal question type will always
remove these trailing '0's and the Numeric ID question type will not allow
'.' characters.

Best,
Will

··· On Thu, Nov 12, 2015 at 10:06 AM, Gurudayal Sahu wrote:

Hi,

We are entering the GPS coordinates values based on the readings display
from the GPS devices and the device display the values in the format as :
"XX.XXXXX" (approx 6 digits after decimal points) and the validation
applied as regex(., '[1][0-9]*(.[0-9][0-9][0-9][0-9][0-9][0-9]?)?$')"
to confirm the same requirementsand it accepts the values like : 25.370121
or 55.100151 etc., but sometime the GPS device display the value as "25.222200"
, "23.076543" and the above validation does not allow to accept any value
with Zero as it is getting round off automatically replacing all the zeros
or (It may be correct for the decimal value). However the round off value
is not correct as per GPS location. Hence i am looking for a validation
format that should accept the value in above same format XX.XXXXXX
accepting values without getting it round off.

Thanks in advance for all the suggestions.

Thanks & regards,
Gurudayal Sahu

--


You received this message because you are subscribed to the Google Groups
"CommCare Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to commcare-developers+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


  1. 0-9 ↩︎

Hi Will,

Thanks for the all the details.

Do we have any validation that can be applied to text data type for the
decimal input values with the same required format (xx.xxxxxx) as the
above regex validation still take the input as decimal type and trailing
'0'.

With regards,
Gurudayal Sahu

··· On Thursday, 12 November 2015 21:01:45 UTC+5:30, William Pride wrote: > > Hello, > > Assuming that you want to retain the trailing '0's then I think the best > option would be to make the GPS entry fields String questions and save > these values as strings, then cast them to doubles when you need to to > validation or other number logic. The Decimal question type will always > remove these trailing '0's and the Numeric ID question type will not allow > '.' characters. > > Best, > Will > > On Thu, Nov 12, 2015 at 10:06 AM, Gurudayal Sahu <guruda...@gmail.com > wrote: > >> Hi, >> >> We are entering the GPS coordinates values based on the readings display >> from the GPS devices and the device display the values in the format as : >> "XX.XXXXX" (approx 6 digits after decimal points) and the validation >> applied as regex(., '^[0-9][0-9]*(\.[0-9][0-9][0-9][0-9][0-9][0-9]?)?$')" >> to confirm the same requirementsand it accepts the values like : 25.370121 >> or 55.100151 etc., but sometime the GPS device display the value as "25.222200" >> , "23.076543" and the above validation does not allow to accept any >> value with Zero as it is getting round off automatically replacing all the >> zeros or (It may be correct for the decimal value). However the round off >> value is not correct as per GPS location. Hence i am looking for a >> validation format that should accept the value in above same format >> XX.XXXXXX accepting values without getting it round off. >> >> Thanks in advance for all the suggestions. >> >> Thanks & regards, >> Gurudayal Sahu >> >> >> >> >> >> >> -- >> >> --- >> You received this message because you are subscribed to the Google Groups >> "CommCare Developers" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to commcare-developers+unsubscribe@googlegroups.com . >> For more options, visit https://groups.google.com/d/optout. >> > >

Gurudayal,

Interesting, I hadn't considered that casting to a double() would likely
remove the trailing zeroes. In that case you might be best off processing
this only using string functions
https://confluence.dimagi.com/display/commcarepublic/CommCare+Functions#CommCareFunctions-StringFunctions.
For example, you could get the substring from 0 to the index of '.' and
assert this to be a certain length, then get the substring from the '.' to
the end and assert this to be a certain length.

Best,
Will

··· On Thu, Nov 12, 2015 at 1:18 PM, Gurudayal Sahu wrote:

Hi Will,

Thanks for the all the details.

Do we have any validation that can be applied to text data type for the
decimal input values with the same required format (xx.xxxxxx) as the
above regex validation still take the input as decimal type and trailing
'0'.

With regards,
Gurudayal Sahu

On Thursday, 12 November 2015 21:01:45 UTC+5:30, William Pride wrote:

Hello,

Assuming that you want to retain the trailing '0's then I think the best
option would be to make the GPS entry fields String questions and save
these values as strings, then cast them to doubles when you need to to
validation or other number logic. The Decimal question type will always
remove these trailing '0's and the Numeric ID question type will not allow
'.' characters.

Best,
Will

On Thu, Nov 12, 2015 at 10:06 AM, Gurudayal Sahu guruda...@gmail.com wrote:

Hi,

We are entering the GPS coordinates values based on the readings display
from the GPS devices and the device display the values in the format as :
"XX.XXXXX" (approx 6 digits after decimal points) and the validation
applied as regex(., '[1][0-9]*(.[0-9][0-9][0-9][0-9][0-9][0-9]?)?$')"
to confirm the same requirementsand it accepts the values like : 25.370121
or 55.100151 etc., but sometime the GPS device display the value as "25.222200"
, "23.076543" and the above validation does not allow to accept any
value with Zero as it is getting round off automatically replacing all the
zeros or (It may be correct for the decimal value). However the round off
value is not correct as per GPS location. Hence i am looking for a
validation format that should accept the value in above same format
XX.XXXXXX accepting values without getting it round off.

Thanks in advance for all the suggestions.

Thanks & regards,
Gurudayal Sahu

--


You received this message because you are subscribed to the Google
Groups "CommCare Developers" group.
To unsubscribe from this group and stop receiving emails from it, send
an email to commcare-developers+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--


You received this message because you are subscribed to the Google Groups
"CommCare Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to commcare-developers+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


  1. 0-9 ↩︎