You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: design/website/docs/value/parse.md
-26Lines changed: 0 additions & 26 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -10,30 +10,4 @@ Example usage is shown below.
10
10
const R =Value.Parse(Type.String(), 'hello') // const R: string = "hello"
11
11
12
12
const E =Value.Parse(Type.String(), 12345) // throws ParseError
13
-
```
14
-
15
-
## Corrective Parse
16
-
17
-
TypeBox provides an optional corrective parsing mode that attempts to repair invalid values before failing. When enabled, the parser runs a pipeline consisting of Convert, Default, and Clean, then re-asserts the value after processing. This feature can be useful when parsing environment variables into target types.
18
-
19
-
> ⚠️ This feature can impact performance. It is not recommended for use in high throughput applications.
20
-
21
-
This feature can be enabled as follows:
22
-
23
-
```typescript
24
-
import { Settings } from'typebox/system'
25
-
26
-
// Corrective Parse: Enable
27
-
28
-
Settings.Set({ correctiveParse: true })
29
-
30
-
// Corrective Parse: Convert Value into the target type if reasonable conversion is possible.
31
-
32
-
const R =Value.Parse(Type.String(), 'hello') // const R: string = "hello"
33
-
34
-
const S =Value.Parse(Type.String(), 12345) // const S: string = "12345"
0 commit comments