add validation function