Add a validation function