Odd Validation Rule Check

Hi All,

I have a form in which I want users to be guided by certain validation
rules but I also have some "special" cases that I want to allow.
As an example, for an age question, I want to validate age to be between 18
and 100 years, but also want the ability to enter something like -65 for
non response or -77 for dont know.
Is this possible or is there another work around?

Kind regards,

Hi Sam,

Most of the time we try to support those workflows using structured
validation rather than "key" inputs.

For Example:

Question List:

  • "What is the person's Age?"
    • id: age_input
    • Validation Condition: 18-100
    • Display Condition: age_unknown = ''
  • Multiple Select Question with no Text
    • id: age_unknown
    • Age is Unknown - value -77
  • Hidden Value
    • id: age_output
    • calculation: if(../age_unknown = -77, -77, if(age_input = '', -65,
      -77)))

That will give you the output of 18-100, -77, or -65 from the hidden value
"age_output", but will give your users the ability to enter either a valid
age, check a box that denotes that the age is unknown, or skip the question
without needing to know the special flags.

-Clayton

··· On Tue, Oct 4, 2016 at 11:27 AM, Sam Phiri wrote:

Hi All,

I have a form in which I want users to be guided by certain validation
rules but I also have some "special" cases that I want to allow.
As an example, for an age question, I want to validate age to be between
18 and 100 years, but also want the ability to enter something like -65 for
non response or -77 for dont know.
Is this possible or is there another work around?

Kind regards,

--
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/d/optout.

whoops, wrote that expression a bit fast. I meant:

  • calculation: if(../age_unknown = -77, -77, if(../age_input = '', -65,
    ../age_input)))
··· On Tue, Oct 4, 2016 at 11:48 AM, Clayton Sims wrote:

Hi Sam,

Most of the time we try to support those workflows using structured
validation rather than "key" inputs.

For Example:

Question List:

  • "What is the person's Age?"
    • id: age_input
    • Validation Condition: 18-100
    • Display Condition: age_unknown = ''
  • Multiple Select Question with no Text
    • id: age_unknown
    • Age is Unknown - value -77
  • Hidden Value
    • id: age_output
    • calculation: if(../age_unknown = -77, -77, if(age_input = '', -65,
      -77)))

That will give you the output of 18-100, -77, or -65 from the hidden value
"age_output", but will give your users the ability to enter either a valid
age, check a box that denotes that the age is unknown, or skip the question
without needing to know the special flags.

-Clayton

On Tue, Oct 4, 2016 at 11:27 AM, Sam Phiri mitoworks21@gmail.com wrote:

Hi All,

I have a form in which I want users to be guided by certain validation
rules but I also have some "special" cases that I want to allow.
As an example, for an age question, I want to validate age to be between
18 and 100 years, but also want the ability to enter something like -65 for
non response or -77 for dont know.
Is this possible or is there another work around?

Kind regards,

--
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/d/optout.

Thanks Clayton

An if statement in the validation seems to work also.Something like if((.

= 18 and . <= 100), true(), if((. = -65), true(), if((. = -77), true(),
false())))
Question: Does having a number of these (100 or more) affect the load speed
of the form?

Kind regards,

··· On 4 October 2016 at 17:48, Clayton Sims wrote:

whoops, wrote that expression a bit fast. I meant:

  • calculation: if(../age_unknown = -77, -77, if(../age_input = '', -65,
    ../age_input)))

On Tue, Oct 4, 2016 at 11:48 AM, Clayton Sims csims@dimagi.com wrote:

Hi Sam,

Most of the time we try to support those workflows using structured
validation rather than "key" inputs.

For Example:

Question List:

  • "What is the person's Age?"
    • id: age_input
    • Validation Condition: 18-100
    • Display Condition: age_unknown = ''
  • Multiple Select Question with no Text
    • id: age_unknown
    • Age is Unknown - value -77
  • Hidden Value
    • id: age_output
    • calculation: if(../age_unknown = -77, -77, if(age_input = '', -65,
      -77)))

That will give you the output of 18-100, -77, or -65 from the hidden
value "age_output", but will give your users the ability to enter either a
valid age, check a box that denotes that the age is unknown, or skip the
question without needing to know the special flags.

-Clayton

On Tue, Oct 4, 2016 at 11:27 AM, Sam Phiri mitoworks21@gmail.com wrote:

Hi All,

I have a form in which I want users to be guided by certain validation
rules but I also have some "special" cases that I want to allow.
As an example, for an age question, I want to validate age to be between
18 and 100 years, but also want the ability to enter something like -65 for
non response or -77 for dont know.
Is this possible or is there another work around?

Kind regards,

--
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/d/optout.

--
You received this message because you are subscribed to a topic in the
Google Groups "commcare-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/
topic/commcare-users/PAl72wddZF4/unsubscribe.
To unsubscribe from this group and all its topics, send an email to
commcare-users+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Sam,

Encoding in the validation condition definitely works as well, yes.

Including validation conditions will have a marginal impact on the speed of
loading the form. At that scale I would not anticipate a meaningful hit to
performance.

-Clayton

··· On Tue, Oct 4, 2016 at 12:17 PM, Sam Phiri wrote:

Thanks Clayton

An if statement in the validation seems to work also.Something like if((.

= 18 and . <= 100), true(), if((. = -65), true(), if((. = -77), true(),
false())))
Question: Does having a number of these (100 or more) affect the load
speed of the form?

Kind regards,

On 4 October 2016 at 17:48, Clayton Sims csims@dimagi.com wrote:

whoops, wrote that expression a bit fast. I meant:

  • calculation: if(../age_unknown = -77, -77, if(../age_input = '',
    -65, ../age_input)))

On Tue, Oct 4, 2016 at 11:48 AM, Clayton Sims csims@dimagi.com wrote:

Hi Sam,

Most of the time we try to support those workflows using structured
validation rather than "key" inputs.

For Example:

Question List:

  • "What is the person's Age?"
    • id: age_input
    • Validation Condition: 18-100
    • Display Condition: age_unknown = ''
  • Multiple Select Question with no Text
    • id: age_unknown
    • Age is Unknown - value -77
  • Hidden Value
    • id: age_output
    • calculation: if(../age_unknown = -77, -77, if(age_input = '', -65,
      -77)))

That will give you the output of 18-100, -77, or -65 from the hidden
value "age_output", but will give your users the ability to enter either a
valid age, check a box that denotes that the age is unknown, or skip the
question without needing to know the special flags.

-Clayton

On Tue, Oct 4, 2016 at 11:27 AM, Sam Phiri mitoworks21@gmail.com wrote:

Hi All,

I have a form in which I want users to be guided by certain validation
rules but I also have some "special" cases that I want to allow.
As an example, for an age question, I want to validate age to be
between 18 and 100 years, but also want the ability to enter something like
-65 for non response or -77 for dont know.
Is this possible or is there another work around?

Kind regards,

--
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/d/optout.

--
You received this message because you are subscribed to a topic in the
Google Groups "commcare-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/to
pic/commcare-users/PAl72wddZF4/unsubscribe.
To unsubscribe from this group and all its topics, send an email to
commcare-users+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-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/d/optout.