Add validation function