Create a validation middleware