Validation function.