Perform simple javascript validation like isEmpty and isDefined in a consistent manner