ResearchKit / ResearchKit

ResearchKit is an open source software framework that makes it easy to create apps for medical research or for other research projects.
https://www.researchandcare.org
Other
5.61k stars 1.16k forks source link

Validate ORKFormSteps with inline validation errors #467

Open md0u80c9 opened 9 years ago

md0u80c9 commented 9 years ago

Partly an issue of style but also partly a future-proofing to permit more complex validation.

At present, ORKFormItems are validated individually, and present a UIAlertController when a validity error is encountered.

In more complex validation scenarios, entering data into the current field may invalidate other fields. The example provided was a house number and UK Postcode: if you changed a postcode field, you may invalidate the house number field (because a postcode often relates to a street of houses, the new street may not have that particular house number on it). Inline validity reporting would mean that if the data management was changed to allow validity checking of all items or interdependence between form items, that the results would be displayed.

The visual effects could be those seen in standard forms: either add a cell row to the table with a red background and the invalidity message. Or use an alert symbol and change the FormItem text red with a validity message in red text below.

YuanZhu-apple commented 9 years ago

Agree, a cross formItem validation can be very useful in many scenarios.

But for the address input example, someone has proposed to cleaner way to solve it:

Provide user one text field plus a map view from MapKit, while the user in typing, 
the location will be updated in the map view. 
If MapKit cannot map a input, then the answer if not valid.

Do you think this ORKAddressStep can improve the experience of address input ?

md0u80c9 commented 9 years ago

The example was really just to give a common example case where cross-form validation would be needed (and hence why in-line validation errors may be more helpful than UIAlertController ones as a step towards cross-form validation).

But I think having postcode data which relates directly to a map would give a better user experience, yes.