validate data in insert and edit methods.