add validate function

a demo validate function is added