Commit da202d1
authored
[bug] Correctly parse enums when other json elements may exist in the string (#1913)
Fixes #1888
<!-- ELLIPSIS_HIDDEN -->
----
> [!IMPORTANT]
> Fixes enum parsing in `field_type.rs` to handle JSON strings with
additional elements, verified by new test in `test_enum.rs`.
>
> - **Behavior**:
> - Fixes enum parsing in `coerce()` in `field_type.rs` to handle cases
where other JSON elements exist in the string.
> - Adds support for `FieldType::Enum(_)` and
`FieldType::Literal(LiteralValue::String(_))` in `matches!` condition.
> - **Tests**:
> - Adds `test_weird_characters` in `test_enum.rs` to verify enum
parsing with additional text and special characters.
>
> <sup>This description was created by </sup>[<img alt="Ellipsis"
src="https://img.shields.io/badge/Ellipsis-blue?color=175173">](https://www.ellipsis.dev?ref=BoundaryML%2Fbaml&utm_source=github&utm_medium=referral)<sup>
for bb03cfa. You can
[customize](https://app.ellipsis.dev/BoundaryML/settings/summaries) this
summary. It will automatically update as commits are pushed.</sup>
<!-- ELLIPSIS_HIDDEN -->1 parent 2acb6d7 commit da202d1
2 files changed
Lines changed: 20 additions & 2 deletions
Lines changed: 2 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | | - | |
| 2 | + | |
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
| |||
33 | 33 | | |
34 | 34 | | |
35 | 35 | | |
36 | | - | |
| 36 | + | |
37 | 37 | | |
38 | 38 | | |
39 | 39 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
293 | 293 | | |
294 | 294 | | |
295 | 295 | | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
0 commit comments