I believe this is what you had in mind when you wrote the is_valid method.