def test_string_config_validation(self):
        class TestConf(schema.Schema):
            item = schema.StringItem(title="Foo", description="Foo Item")

        try:
            jsonschema.validate({"item": "the item"}, TestConf.serialize())
        except jsonschema.exceptions.ValidationError as exc:
            self.fail("ValidationError raised: {}".format(exc))

        class TestConf(schema.Schema):
            item = schema.StringItem(
                title="Foo", description="Foo Item", min_length=1, max_length=10
            )

        try:
            jsonschema.validate({"item": "the item"}, TestConf.serialize())
        except jsonschema.exceptions.ValidationError as exc:
            self.fail("ValidationError raised: {}".format(exc))

        with self.assertRaises(jsonschema.exceptions.ValidationError) as excinfo:
            jsonschema.validate({"item": 3}, TestConf.serialize())
        self.assertIn("is not of type", excinfo.exception.message)

        with self.assertRaises(jsonschema.exceptions.ValidationError) as excinfo:
            jsonschema.validate({"item": "the item the item"}, TestConf.serialize())
        self.assertIn("is too long", excinfo.exception.message)

        class TestConf(schema.Schema):
            item = schema.StringItem(
                title="Foo", description="Foo Item", min_length=10, max_length=100
            )

        with self.assertRaises(jsonschema.exceptions.ValidationError) as excinfo:
            jsonschema.validate({"item": "the item"}, TestConf.serialize())
        self.assertIn("is too short", excinfo.exception.message)

        class TestConf(schema.Schema):
            item = schema.StringItem(
                title="Foo", description="Foo Item", enum=("foo", "bar")
            )

        try:
            jsonschema.validate({"item": "foo"}, TestConf.serialize())
        except jsonschema.exceptions.ValidationError as exc:
            self.fail("ValidationError raised: {}".format(exc))

        class TestConf(schema.Schema):
            item = schema.StringItem(
                title="Foo", description="Foo Item", enum=("foo", "bar")
            )

        with self.assertRaises(jsonschema.exceptions.ValidationError) as excinfo:
            jsonschema.validate({"item": "bin"}, TestConf.serialize())
        self.assertIn("is not one of", excinfo.exception.message)

        class TestConf(schema.Schema):
            item = schema.StringItem(
                title="Foo", description="Foo Item", pattern=r"^([\w_-]+)$"
            )

        try:
            jsonschema.validate(
                {"item": "the-item"},
                TestConf.serialize(),
                format_checker=jsonschema.FormatChecker(),
            )
        except jsonschema.exceptions.ValidationError as exc:
            self.fail("ValidationError raised: {}".format(exc))

        with self.assertRaises(jsonschema.exceptions.ValidationError) as excinfo:
            jsonschema.validate(
                {"item": "the item"},
                TestConf.serialize(),
                format_checker=jsonschema.FormatChecker(),
            )
        self.assertIn("does not match", excinfo.exception.message)