def test_validate_only_if_not_none(self): field = StringField(required=False) expect(field.validate(None)).to_be_true()
def test_validate_enforces_maxlength(self): field = StringField(max_length=5) expect(field.validate("-----")).to_be_true() expect(field.validate("-----" * 2)).to_be_false()
def test_validate_enforces_strings(self): field = StringField(max_length=5) expect(field.validate(1)).to_be_false()