add validate function
Merge pull request #2 from AndyYou/master

add validate function