Conflict between validation and question type?

Hi,

I have several decimal type questions that have validation conditions on
their string length.

For example a question on baby weight that is measured in kilogrammes is a
decimal question and has the validation:

. <= 10 and . >= 2.5 and string-length(.) = 3

because I want to make sure that the entries are e.g. 3.3 and not just 3

But this is causing us a problem if the weight is 3.0. I am guessing that
the decimal question is rounding this down to 3 and this then doesn't meet
the validation condition of string length = 3. It's giving me the strange
situation where no babies have a weight ending in 0!

Does anyone have any ideas / suggestions how I can get around this, or is
the only way to remove the string length validation and take the risk?

Thanks

Jenny

Hey Jenny,

For this sort of thing its generally best to use a regular expression. You
can find the syntax for using them in your form
herehttps://confluence.dimagi.com/display/commcarepublic/CommCare+Functions#CommCareFunctions-regexand
there are plenty of resources for learning about and generating
regular
expression online.

In this case (weight less than 10.0 and greater than 2.5 with exactly one
decimal place) you could use the constraint:

constraint=". <= 10 and . > 2.5 and regex(., '[1]*.[0-9]$' )"

In your bind.

Best of luck,
Will

··· On Fri, Jul 26, 2013 at 6:22 AM, Jennifer Hall wrote:

Hi,

I have several decimal type questions that have validation conditions on
their string length.

For example a question on baby weight that is measured in kilogrammes is a
decimal question and has the validation:

. <= 10 and . >= 2.5 and string-length(.) = 3

because I want to make sure that the entries are e.g. 3.3 and not just 3

But this is causing us a problem if the weight is 3.0. I am guessing that
the decimal question is rounding this down to 3 and this then doesn't meet
the validation condition of string length = 3. It's giving me the strange
situation where no babies have a weight ending in 0!

Does anyone have any ideas / suggestions how I can get around this, or is
the only way to remove the string length validation and take the risk?

Thanks

Jenny

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


  1. 0-9 ↩︎

Hey Jenny,

Just for everyone's future reference we have documentation about this on
our help site:
https://confluence.dimagi.com/display/commcarepublic/Common+Logic+and+Calculations#CommonLogicandCalculations-RequireSignificantFiguresforNumericInputs

The "common logic and calculations" page is very useful if you're
interested in advanced logic!

Thanks,
Amelia

··· On Fri, Jul 26, 2013 at 6:09 PM, William Pride wrote:

Hey Jenny,

For this sort of thing its generally best to use a regular expression. You
can find the syntax for using them in your form herehttps://confluence.dimagi.com/display/commcarepublic/CommCare+Functions#CommCareFunctions-regexand there are plenty of resources for learning about and generating regular
expression online.

In this case (weight less than 10.0 and greater than 2.5 with exactly one
decimal place) you could use the constraint:

constraint=". <= 10 and . > 2.5 and regex(., '[1]*.[0-9]$' )"

In your bind.

Best of luck,
Will

On Fri, Jul 26, 2013 at 6:22 AM, Jennifer Hall jenny_hall33@yahoo.co.ukwrote:

Hi,

I have several decimal type questions that have validation conditions on
their string length.

For example a question on baby weight that is measured in kilogrammes is
a decimal question and has the validation:

. <= 10 and . >= 2.5 and string-length(.) = 3

because I want to make sure that the entries are e.g. 3.3 and not just 3

But this is causing us a problem if the weight is 3.0. I am guessing
that the decimal question is rounding this down to 3 and this then doesn't
meet the validation condition of string length = 3. It's giving me the
strange situation where no babies have a weight ending in 0!

Does anyone have any ideas / suggestions how I can get around this, or is
the only way to remove the string length validation and take the risk?

Thanks

Jenny

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

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


  1. 0-9 ↩︎

Thank you both!

I thought I had read the common logic and calculations page to death but I
guess that I didn't realise that that was what I needed.

Jenny

··· On Friday, July 26, 2013 5:19:57 PM UTC+2, Amelia Sagoff wrote: > > Hey Jenny, > > Just for everyone's future reference we have documentation about this on > our help site: > https://confluence.dimagi.com/display/commcarepublic/Common+Logic+and+Calculations#CommonLogicandCalculations-RequireSignificantFiguresforNumericInputs > > The "common logic and calculations" page is very useful if you're > interested in advanced logic! > > Thanks, > Amelia > > > On Fri, Jul 26, 2013 at 6:09 PM, William Pride <wpr...@dimagi.com wrote: > >> Hey Jenny, >> >> For this sort of thing its generally best to use a regular expression. >> You can find the syntax for using them in your form hereand there are plenty of resources for learning about and generating regular >> expression online. >> >> In this case (weight less than 10.0 and greater than 2.5 with exactly one >> decimal place) you could use the constraint: >> >> constraint=". <= 10 and . > 2.5 and regex(., '^[0-9]*\.[0-9]$' )" >> >> In your bind. >> >> Best of luck, >> Will >> >> >> >> On Fri, Jul 26, 2013 at 6:22 AM, Jennifer Hall <jenny_...@yahoo.co.uk wrote: >> >>> Hi, >>> >>> I have several decimal type questions that have validation conditions on >>> their string length. >>> >>> For example a question on baby weight that is measured in kilogrammes is >>> a decimal question and has the validation: >>> >>> . <= 10 and . >= 2.5 and string-length(.) = 3 >>> >>> because I want to make sure that the entries are e.g. 3.3 and not just 3 >>> >>> But this is causing us a problem if the weight is 3.0. I am guessing >>> that the decimal question is rounding this down to 3 and this then doesn't >>> meet the validation condition of string length = 3. It's giving me the >>> strange situation where no babies have a weight ending in 0! >>> >>> Does anyone have any ideas / suggestions how I can get around this, or >>> is the only way to remove the string length validation and take the risk? >>> >>> Thanks >>> >>> Jenny >>> >>> -- >>> You received this message because you are subscribed to the Google >>> Groups "commcare-users" group. >>> To unsubscribe from this group and stop receiving emails from it, send >>> an email to commcare-user...@googlegroups.com . >>> For more options, visit https://groups.google.com/groups/opt_out. >>> >>> >>> >> >> -- >> You received this message because you are subscribed to the Google Groups >> "commcare-users" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to commcare-user...@googlegroups.com . >> For more options, visit https://groups.google.com/groups/opt_out. >> >> >> > >