Object oriented client side validation - JavaScript