| 481 | ], |
| 482 | ) |
| 483 | def test_pattern(self, proto, pattern, good, bad): |
| 484 | class Ex(msgspec.Struct): |
| 485 | x: Annotated[str, Meta(pattern=pattern)] |
| 486 | |
| 487 | dec = proto.Decoder(Ex) |
| 488 | |
| 489 | for x in good: |
| 490 | assert dec.decode(proto.encode(Ex(x))).x == x |
| 491 | |
| 492 | err_msg = f"Expected `str` matching regex {pattern!r} - at `$.x`" |
| 493 | for x in bad: |
| 494 | with pytest.raises(msgspec.ValidationError) as rec: |
| 495 | dec.decode(proto.encode(Ex(x))) |
| 496 | assert str(rec.value) == err_msg |
| 497 | |
| 498 | @pytest.mark.parametrize( |
| 499 | "meta, good, bad", |