Self define validate function