Ios validating text input
What happens if we need a common solution for our favorite target platforms: Windows 10 UAP, Android and i OS?
As DRY principle lovers, we always think about reusing as many code artifacts as possible.
After a small research about validation engine provided by UAP platform, we found this great article by Jerry Nixon, that we recommend as a very interesting read.
It seems that we need to create some custom validation classes, so we can work in our own solution with Jerry’s approach as source of inspiration.
For example, if you’re implementing a search field, you might want to update the search results as the user types their query.
If user introduces an invalid value, a red message should appear.
For UAP, an easy approach is to extend core Textbox, creating a new class called Validation Text Box, and modifying its control template to add a custom red Text Block bound to property first error message.
Other interesting subscription is the one related with view model Property Changed.
In this case, we can use the property to enable or disable submit button.
Again, we need to subscribe to some control events to provide automatic validation: Editing Changed and Editing Did End events.