Fixed validation middleware