Move the textinput validation into a class.