Decompose monolithic readme into docs/ directory structure
This commit is contained in:
25
docs/values/decode-encode.md
Normal file
25
docs/values/decode-encode.md
Normal file
@@ -0,0 +1,25 @@
|
||||
[Overview](../overview.md) | [Installation](../installation.md) | [Usage](../usage.md) | [Types](../types/) | **Values** | [Syntax](../syntax/) | [TypeRegistry](../type-registry.md) | [TypeCheck](../type-check.md)
|
||||
|
||||
# Decode / Encode
|
||||
|
||||
## Decode
|
||||
|
||||
Use the Decode function to decode a value from a type or throw if the value is invalid. The return value will infer as the decoded type. This function will run Transform codecs if available.
|
||||
|
||||
```typescript
|
||||
const A = Value.Decode(Type.String(), "hello"); // const A = 'hello'
|
||||
|
||||
const B = Value.Decode(Type.String(), 42); // throw
|
||||
```
|
||||
|
||||
## Encode
|
||||
|
||||
Use the Encode function to encode a value to a type or throw if the value is invalid. The return value will infer as the encoded type. This function will run Transform codecs if available.
|
||||
|
||||
```typescript
|
||||
const A = Value.Encode(Type.String(), "hello"); // const A = 'hello'
|
||||
|
||||
const B = Value.Encode(Type.String(), 42); // throw
|
||||
```
|
||||
|
||||
Back to [Home](../../readme.md)
|
||||
Reference in New Issue
Block a user