generate and isValid with tests