Decompose monolithic readme into docs/ directory structure
This commit is contained in:
20
docs/values/default.md
Normal file
20
docs/values/default.md
Normal file
@@ -0,0 +1,20 @@
|
||||
[Overview](../overview.md) | [Installation](../installation.md) | [Usage](../usage.md) | [Types](../types/) | **Values** | [Syntax](../syntax/) | [TypeRegistry](../type-registry.md) | [TypeCheck](../type-check.md)
|
||||
|
||||
# Default
|
||||
|
||||
Use Default to generate missing properties on a value using default schema annotations if available. This function does not check the value and returns an unknown type. You should Check the result before use. Default is a mutable operation. To avoid mutation, Clone the value first.
|
||||
|
||||
```typescript
|
||||
const T = Type.Object({
|
||||
x: Type.Number({ default: 0 }),
|
||||
y: Type.Number({ default: 0 }),
|
||||
});
|
||||
|
||||
const X = Value.Default(T, null); // const 'X = null - non-enumerable
|
||||
|
||||
const Y = Value.Default(T, {}); // const 'Y = { x: 0, y: 0 }
|
||||
|
||||
const Z = Value.Default(T, { x: 1 }); // const 'Z = { x: 1, y: 0 }
|
||||
```
|
||||
|
||||
Back to [Home](../../readme.md)
|
||||
Reference in New Issue
Block a user