create validation function