Added validation function and documentation